autobahn-js
autobahn-js copied to clipboard
Subprotocol error when creating connection with [email protected]
The 8.0.0
version of ws
introduced some breaking changes around protocols. Attempting to create a connection with this version yields the following error.
could not create WAMP transport 'websocket': SyntaxError: An invalid or duplicated subprotocol was specified
at initAsClient (C:\Users\BenHanna\source\repos\wamp\node_modules\ws\lib\websocket.js:677:15)
at new WebSocket (C:\Users\BenHanna\source\repos\wamp\node_modules\ws\lib\websocket.js:80:7)
at C:\Users\BenHanna\source\repos\wamp\node_modules\autobahn\lib\transport\websocket.js:200:22
at Factory.create (C:\Users\BenHanna\source\repos\wamp\node_modules\autobahn\lib\transport\websocket.js:288:9)
at Connection._create_transport (C:\Users\BenHanna\source\repos\wamp\node_modules\autobahn\lib\connection.js:112:44)
at retry (C:\Users\BenHanna\source\repos\wamp\node_modules\autobahn\lib\connection.js:249:33)
at Connection.open (C:\Users\BenHanna\source\repos\wamp\node_modules\autobahn\lib\connection.js:383:4)
at Object.<anonymous> (C:\Users\BenHanna\source\repos\wamp\index.js:65:16)
at Module._compile (internal/modules/cjs/loader.js:1072:14)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1101:10)
could not create any WAMP transport
Rolling back to 7.5.3
makes the issue go away.
Using >= instead of default ^ in the package.json file is causing the problem. A major version of ws module is getting installed, and it is breaking the autobahn module. Why are we using >= in package.json? Is there a reason?
I see. You are supporting from ws v1.0.
Can you put an upper limit to the dependency module versions so that they don't break autobahn in future. https://semver.npmjs.com/
Hello, everyone! Are there any good news on this issue? :)
I used the npm-force-resolutions
package for my project as a workaround for this issue to point to the non-broken ws version 7.5.3.
I'm not sure what the state of this issue is, but I tested with ws v8.6.0
and the reason it's erroring is that there's a regex test failing. Autobahn passes both JSON and webpack serialization split by a comma, but ws
is expecting an array.
I removed the join statement to pass an array and it's working beautifully now. Does it make sense to migrate to v8 and remove that?
@oberstet
It seems like you're maintaining the repository
The small change (removing the join
and upgrading to the new ws version) can make users' lifes better. If that's too much - the condition may be added to check ws
version before joining protocols.
We already have a PR for a quick fix: https://github.com/crossbario/autobahn-js/pull/552, I can create a PR for a proper one.
just a quick note, what @DamiToma suggests sounds good! @luixo no need for checking for old ws version, we can just bump the minimum version required to v8.6. so yeah, a PR would be awesome, I can merge ..
@oberstet I would suggest to also update the README, as it can be misleading for newbies. Initially I thought it supported up to version 2, we can probably get rid of the comment for Node V4.5.0 (I guess no one has been using that for years).