Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Timeout value is being ignored - a 75 sec timeout is used instead #429

Closed
lmsmartins opened this issue Nov 23, 2017 · 3 comments
Closed

Comments

@lmsmartins
Copy link

Hi,

I'm using version 3.0 with Swift 4.

When connecting to a web socket server, the timeout interval is being ignored, since the "disconnect" callback is only triggered after 75 seconds, instead of the timeout value that I define (I've tried several values like 5 or 10 seconds, but I get the same result).

In order to test the timeout, I'm disabling the WiFi in my iPhone before trying to establish a connection with a web socket server.

Here's the code snippet I'm using when defining the url timeout:

            var urlRequest = URLRequest(url: url)
            urlRequest.timeoutInterval = TimeInterval(10)
            webSocket = WebSocket(request: urlRequest)

Is there anything I could be doing wrong?

Thanks!

@lmsmartins
Copy link
Author

lmsmartins commented Nov 24, 2017

I've also tried to implement my own login timeout logic, using a dispatch source timer, and by forcing the web socket to disconnect when the timeout is reached. However, I'm not able to interrupt an on-going connection attempt when forcing the web socket to disconnect:

webSocket.disconnect(forceTimeout: TimeInterval(0))

The connection only times out after 75 seconds.

Does the disconnect function only work after a connection is successfully established?

@daltoniam
Copy link
Owner

Ah yes, the timeout was broken in 3.0 release. Thanks for the report, this has been fixed in the 3.0.4 release!

@brunomorgado
Copy link

I'm experiencing the exact same issue on 3.0.4. I have my own timeout which forces the connection to be shut down. Using webSocket.disconnect(forceTimeout: TimeInterval(0)) freezes the UI for more than a minute. Odd thing is, if I use webSocket.disconnect(forceTimeout: nil) I manage to shut down and reestablish the connection.

Do you have any thoughts on what the issue might be? Can you confirm that 3.0.4 includes the fix?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants