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

Stream end encountered #17

Closed
starlight173 opened this issue Feb 7, 2018 · 9 comments
Closed

Stream end encountered #17

starlight173 opened this issue Feb 7, 2018 · 9 comments

Comments

@starlight173
Copy link

Sometime I get disconnect issue because of stream end encountered error.

didCloseWithCode 1001, reason: Optional("Stream end encountered")
StompClientDidDisconnect

The server is still in operation. I think this comes from SocketRocket. Do you have any idea about this issue?

@starlight173
Copy link
Author

This is NGiNX issue.

@SSUS31
Copy link

SSUS31 commented Aug 6, 2019

Always facing this issue. Automatic disconnected after 30-40 seconds

didCloseWithCode 1001, reason: Optional("Stream end encountered")
StompClientDidDisconnect

@WrathChaos
Copy link
Owner

@SSUS31 Maybe @gloryluu will tell you how did he/she fix the problem. This is not related to StompClientLib.

@starlight173
Copy link
Author

As I remember, it related to the heart beat. Workaround is to ping pong the server every 30s to maintain the connection

@SSUS31
Copy link

SSUS31 commented Aug 6, 2019

Can you show please how to do it.
@WrathChaos, didn't you face this kind of ping or heart-beat issue?

@starlight173
Copy link
Author

starlight173 commented Aug 6, 2019

There're 2 ways to fix in my situation, either:
1/ You put a timer for every 30s to send a ping command to server. Check in the lib source you will see how he handled it:

socket?.send(StompCommands.commandPing)

or

2/ You ask server to send you a ping ( heartbeat - built in config) and let the lib handle over all for you.

@codedentwickler
Copy link

Hi @gloryluu, how did you ping the server using this library? I can't seem to find out how to do this.

@SSUS31
Copy link

SSUS31 commented Dec 9, 2019

i called this with a Timer for every 20 seconds
self.socketClient.openSocketWithURLRequest(request: NSURLRequest(url: url as URL), delegate: self as StompClientLibDelegate, connectionHeaders: ["Authorization" : "Bearer xyz)", "heart-beat": "0,10000"])

@codedentwickler
Copy link

Oh, I see, that works thank you. Another thing I tried is calling socket client.openSocketWithURLRequest(...) only when stompClientDidDisconnect(client: StompClientLib!) is called. However, there is a chance you might miss a message. So I make sure to verify the status with our backend whenever it reconnects.

In my case calling it every 20 seconds seems inefficient as the backend doesn't kick us out, (i.e socket disconnects) until after a long time (usually over a minute). So I only try to reconnect when the socket disconnects.

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

No branches or pull requests

4 participants