jmesnil / stomp-websocket

Stomp client for Web browsers and node.js apps
http://jmesnil.net/stomp-websocket/doc/
Apache License 2.0
1.43k stars 586 forks source link

TypeError: Cannot read property 'sendUTF' of null. wrapWs function connection is set to null. #132

Open jjwallaby opened 7 years ago

jjwallaby commented 7 years ago

TypeError: Cannot read property 'sendUTF' of null. wrapWs function connection is set to null. line 62 stomp-node.js fails.
wrapWS = function(url) { var WebSocketClient, connection, socket, ws; WebSocketClient = require('websocket').client; connection = null; ws = { url: url, send: function(d) { return connection.sendUTF(d);

Example call :

when use stomp over WS var client = Stomp.overWS('ws://localhost:61614/stomp');

wazcov commented 6 years ago

Did you solve this

snieguu commented 5 years ago

As a workaround add some sleep after Stomp.overWS to allow establish the connection

mikezzb commented 3 years ago

It may because you used the client before connection is established, you can try to call client functions inside connectCallBack (second parameter of the connect function) after connection has been established.