WrathChaos/StompClientLib

didCloseWithCode 1001, reason: "Stream end encountered"

DanielCreagh opened this issue · 4 comments

I am receiving this error consistently after 60 seconds of successfully establishing a socket connection. Regardless of successfully subscribing and receiving messages from sockets server, the connection will always be closed at approximately 1 minute after connecting.

I can't see any way of configuring the ping/pong functionality or any timeout configuration either.

This renders this library useless.

Is anyone else having this issue? It is a shame because otherwise the library functionality is awesome.

Hello @DanielCreagh

From RFC 6455:

1001 indicates that an endpoint is "going away", such as a server
going down or a browser having navigated away from a page.

Resource: Stackoverflow

You should control the stompclient connection when changing the new ViewController or any kinds of stuff. Also, please check your server side part for connection refuse, timeout etc.. If your endpoint connection is goes down, normally your stream connection ends. Moreover, you should handle this issue as well. If you cannot find the solution, please write back :)

One more thing, please try another fully working stream server and let see if you encounter this issue again.
Have fun !

We have Android and Web clients using same websockets server and neither have this issue. :-(

We are using a singleton instance of a web sockets controller that persists throughout entire execution of app, it isn't connected to any view controllers or anything that can be deallocated etc.

I've tried on device and on simulator on different networks and all demonstrate same behaviour.

Is there a way to configure ping/pong functionality?

There is a ping/pong functionality but it still needs some work to do. Please check this issue: #18

i've found the fix for this issue:

socketClient.openSocketWithURLRequest(request: NSURLRequest.initForWebsockets(),
                                          delegate: self,
                                          connectionHeaders: ["Authorization" : "Bearer xyz)", "heart-beat": "0,10000"])

The addition of the heart-beat header (as mentioned in ticket #18) has created consistent traffic over the web socket and hence keeps the socket open.

Thanks for your help, and great work with the library! 🙂🙃🙂