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

Cant connect to socket with namespace in version 13.1.0 #923

Closed
vsergeev1988 opened this issue Jan 6, 2018 · 7 comments
Closed

Cant connect to socket with namespace in version 13.1.0 #923

vsergeev1988 opened this issue Jan 6, 2018 · 7 comments

Comments

@vsergeev1988
Copy link

Hi there! I am trying to connect the websocket on the backend using the latest 13.1.0. Here is my source code:

    let manager: SocketManager

    required init() {
        self.manager = SocketManager(socketURL: Consts.Api.apiUrl,
                config: [SocketIOClientOption.path("/api/v1/communication/socket.io"),
                         SocketIOClientOption.log(true),
                         SocketIOClientOption.extraHeaders(
                                 ["Authorization": "<auth token>"]
                         )])
    }

    func connect() {
        let namespaceSocket = self.manager.socket(forNamespace: "/testRoom1")
        self.addHandlers(namespaceSocket)
        namespaceSocket.connect()
    }

Unfortunately, I receive an error from the backend:

Error decoding socket IO packet '0/testRoom1': Expected ',' to end namespace declaration

Maybe "," is missed in -[SocketManager connectSocket:] where connection command is creating, just like "," is adding after namespace in [SocketPacket createPacketString] method?
Same for -[SocketManager disconnectSocket:].

Or maybe I have an error in my code?

Thank you!

@nuclearace
Copy link
Member

What server version are you using?

@vsergeev1988
Copy link
Author

On the backend we have this: https://github.com/playframework/play-socket.io

We made some tests and was trying to connect to our backend using official JS client (https://github.com/socketio/socket.io-client) and it works ok with this server. The command, received on the backend from this JS client was "0/testRoom1," - with the comma after namespace.

@nuclearace
Copy link
Member

Hm, I guess you're right. I'll update the namespace joining code. Although the JS server seems to work without this trailing ,.

@nuclearace
Copy link
Member

@vsergeev1988 If you could see if the latest development branch fixes it, that'd be helpful.

@vsergeev1988
Copy link
Author

vsergeev1988 commented Jan 7, 2018

@nuclearace I have updated to the latest development branch and it works ok now on connect to namespace, but I still have the same error on disconnect.

@nuclearace
Copy link
Member

Derp, should be fixed now.

@vsergeev1988
Copy link
Author

@nuclearace works great now, thank you!

nuclearace added a commit that referenced this issue Jan 10, 2018
* development:
  fix insert invoked twice
  add , to disconnect
  update changelog
  Fix #923
  update reconnect documentation
  update starscream
  Fix #894
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

2 participants