WebSocketClient is not a constructor
See original GitHub issueI am using browserify
to run lgtv
in the browser, and lgtv
uses websocket.client
for communication with TV.
However, when I use the bundled .js that was given to me by browserify
, I got this error:
Uncaught TypeError: WebSocketClient is not a constructor
Here is some code from the bundled .js file:
var WebSocketClient = require('websocket').client; // for communication with TV
var client = new WebSocketClient();
The problematic line is this:
var client = new WebSocketClient();
Can anyone help?
Issue Analytics
- State:
- Created 7 years ago
- Reactions:4
- Comments:14
Top Results From Across the Web
Uncaught TypeError: WebSocketClient is not a constructor
I have exported websocket using browserify , browserify -r websocket > bundle.js. Then I try to run following code in my browser
Read more >WebSocket is not a constructor - Bugzilla@Mozilla
Calling `new WebSocket()` results in a TypeError: "WebSocket is not a constructor".
Read more >Uncaught TypeError: WebSocketClient is not a constructor
Anyone else getting this? My code is as follows... const wsUri = "ws://localhost:8080/prices/websocket"; const client = Stomp.overWS(wsUri);.
Read more >RSocketWebsocketClient - rsocket-js
The RSocketWebsocketClient implements the RScocket protocol using the WebSocket network transport protocol, and is suitable for Server to Server, and Client ...
Read more >Class WebSocketClient - Terra.js
An object repesenting a connection to a Terra node's WebSocket RPC endpoint. ... 0 for not to attempt reconnect, -1 for infinite, >...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Guys, in browser you cannot use WebSocketClient class as it’s just for Node (it uses Node stuff not available in the browser).
In the browser you should just use the native WebSocket class. And, just if you are developing an app that must run in browser and Node and must behave as a WebSocket client, then use:
var W3CWebSocket = require(‘websocket’).w3cwebsocket;
In fact, when in the browser, such a W3CWebSocket class is just an alias to the native browser WebSocket class. And in Node it’s just a wrapper over Node-WebSocket.WebSocketClient that offers an API similar to the W3 WebSocket class in the browser.
Still have a same issue. Pls check and let me know pls