Closed lmcd closed 5 months ago
Ok I've noticed you can determine this in a .completed
message, which doesn't seem ideal.
Also it seems like you have to fully wait 60 seconds for the connection to timeout before this is delivered. So if the server returns a 401 or something, to indicate the user is not authorised to access this WebSocket endpoint, the user must wait an entire minute for it to timeout.
For websockets, any failed upgrade is considered a failure, and then returned as part of the completed
event, as you saw. If you want to see those events separately, you can use the .validate()
method (I'm pretty sure I tested that). There's no 60s timeout on Alamofire's side, it should just end immediately. So that's either a server behavior or the failed upgrade isn't immediately completing the task locally.
I'm going to convert this to a discussion, we can open an issue for anything that needs to be fixed after investigation.
I'm trying to figure out at what point a
WebSocketRequest
will throw an error if a bad response code comes back. It feels like step 1 would be tovalidate
the request against a list of response codes, like any other request, but this functionality seems missing.If, for example a server throws a 500 error, where would this be intercepted client-side?