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

Didconnect function cannot be callback after successful connection #43

Closed
yongjunta opened this issue May 23, 2019 · 15 comments
Closed
Assignees

Comments

@yongjunta
Copy link

When the connection with the server is successful, the console also prints WebSocket is connected, but there is no callback to stompClientDidConnect method, why?

@WrathChaos
Copy link
Owner

Hello @yongjunta,
Thank you so much for using the lib and create an issue about it :)
This library is more than 2 years old therefore, I did not need a callback method for stompClientDidConnect method. Also, I believe that people can create a business logic with this protocol method.
Of course, PR's are welcome for this little feature :)

@yongjunta
Copy link
Author

yongjunta commented May 23, 2019 via email

@yhz82415
Copy link

yhz82415 commented Jun 5, 2019

I am having the same issue ... ...

Here's what i did:

In my viewDidLoad(), I put
socketClient.openSocketWithURLRequest(request: NSURLRequest(url: url as URL) , delegate: self as StompClientLibDelegate)

it never reaches the method stompClientDidConnect :
func stompClientDidConnect(client: StompClientLib!) { print("Socket is Connected : ") socketClient.subscribe(destination: "/user/topic/greetings") socketClient.subscribe(destination: "/user/topic/finish") socketClient.autoDisconnect(time: 5) // Reconnect after 4 sec socketClient.reconnect(request: NSURLRequest(url: url as URL) , delegate: self as StompClientLibDelegate, time: 4.0) }

I did some debugging. In StompClientLib.sendFrame(), it always goes into the if statement:

if socket?.readyState == .OPEN { socket?.send(frameString) } else { if let delegate = delegate { DispatchQueue.main.async(execute: { delegate.stompClientDidDisconnect(client: self) }) } }
and skip the else... ... So it never reached my delegate method.

@yhz82415
Copy link

yhz82415 commented Jun 6, 2019

I guess in order to make it work it needs this commit:

https://github.com/WrathChaos/StompClientLib/commit/ba521b4ddd32ce48fa63d00439c76af8b165d673

specifically this line // Support for Spring Boot 2.1.x connectionHeaders = [StompCommands.commandHeaderAcceptVersion:"1.1,1.2"] is needed for spring boot. If you're also using it that could fix it

@WrathChaos
Copy link
Owner

Hello @yhz82415,
That commit is the latest version of the StompClientLib, did it solve your issue ?

@yongjunta
Copy link
Author

yongjunta commented Jun 6, 2019 via email

@WrathChaos
Copy link
Owner

@yongjunta, which version are you working on?

@yongjunta
Copy link
Author

The swift 4.2 I used at the time

@yongjunta
Copy link
Author

1.2.7,The swift 4.2 I used at the time

@WrathChaos
Copy link
Owner

Can you try 1.3.0 version with Swift 4.2? It should have been supported with the latest version.

@yhz82415
Copy link

yhz82415 commented Jun 6, 2019

Hello @yhz82415,
That commit is the latest version of the StompClientLib, did it solve your issue ?

Is the latest version 1.3.0? If so there are 3 commits in that version but doesn't have the commit for spring boot support ba521b4 . 1.3.0...master

@yhz82415
Copy link

yhz82415 commented Jun 6, 2019

Hello @yhz82415,
That commit is the latest version of the StompClientLib, did it solve your issue ?

Is the latest version 1.3.0? If so there are 3 commits in that version but doesn't have the commit for spring boot support ba521b4 . 1.3.0...master

nvm it is there

@WrathChaos
Copy link
Owner

@yongjunta, still waiting for you to close this issue :)

@duannl
Copy link

duannl commented Jun 22, 2019

@WrathChaos Hi there. I did checkout version 1.3.1 but I don't see the below commit
https://github.com/WrathChaos/StompClientLib/commit/ba521b4ddd32ce48fa63d00439c76af8b165d673
After testing with this commit, it's working now :)

@WrathChaos
Copy link
Owner

Good to hear @duannl :)

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