Skip to content

Fixed loosing POST packets on web socket connection failure #1034

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

Merged
merged 2 commits into from
Jun 7, 2018
Merged

Fixed loosing POST packets on web socket connection failure #1034

merged 2 commits into from
Jun 7, 2018

Conversation

OneSman7
Copy link
Contributor

@OneSman7 OneSman7 commented Jun 7, 2018

Fixed loosing POST packets on web socket connection failure and engine memory leak on server errors.

@@ -371,6 +371,9 @@ open class SocketEngine : NSObject, URLSessionDelegate, SocketEnginePollable, So
fastUpgrade = false
probing = false
flushProbeWait()
if postWait.count != 0 {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about a !.isEmpty?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No problem, I just copied existing code.

Copy link
Member

@nuclearace nuclearace Jun 7, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or maybe move that check into flush... as a guard and unconditionally call it?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was in flushProbeWait(). That was the problem since this method needs to be called on web socket success and failure, but flushWaitingForPostToWebSocket() only on success. If called on failure, POST packets are just dropped into failed socket.
Another way will be to check in flushWaitingForPostToWebSocket() if socket is connected.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm fine with this way in that case! Would you mind also adding some documentation comments to these methods that explain this failure case? I think those will be helpful when I come back in 6 months and try to refactor and end up breaking it again :).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👌 will also change to !.isEmpty and test

@nuclearace nuclearace merged commit f7ccf33 into socketio:development Jun 7, 2018
@OneSman7 OneSman7 deleted the Fix-loosing-packets-on-websocket-connect-failure branch June 7, 2018 10:48
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

Successfully merging this pull request may close these issues.

2 participants