Hey all,
I’ve an Oban worker making a connection to a remote MSSQL DB to run a query and then process the results.
We’re using Tds to manage this and it works great when everything’s set up correctly.
Every now and again the underlying VPN isn’t established and despite the correct DB creds, the connection will fail resulting in a logged error:
[error] Tds.Protocol (#PID<0.864.0>) failed to connect: ** (Tds.Error) tcp connect: econnrefused
My frustration is that the initial connection function start_link/1
will almost always return {:ok, <pid>}
so attempts to have a try rescue
block aren’t matching – even without DB creds I get the ok tuple then a :killed
error and shell reset (locally).
I’m hoping to to find a way to catch this error, handle the case and let the worker just retry. A Sentry issue is pointing to DBConnection for the source of the error, but I’m not certain how I can use that info.
Appreciate any insight