-
Notifications
You must be signed in to change notification settings - Fork 201
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
Error: No valid WebSocket class provided #135
Comments
It's url, type, options, |
This library basically adds automatic reconnection and passes through everything you pass to it to what you define as WebSocket, so you don't need to use it directly, just tell the reconnecting websocket what to do instead. |
Good morning, first of all, thank you very much for your help, I have made the suggested changes and the error has disappeared. My code is this currently `const WS = require('ws');
} again, thank you very much for your time. |
I'm unsure what the solution to this is |
@shamoons, In my case in the options was to change
to
I needed to change the .on to .addEventListener and the code ran. Funny enough I am also using the ocpp node red client. Once I get it working I will create a pull request to ocpp node red to update it. Hope this helps |
@mastin-zgz I have created a pull request to the node-red-contrib-ocpp library but in the mean time to get this working, you will need to change occurrence of ws.on to ws.addEventListener and in
there may be other issues but they should be raised with node-red-ocpp not @TheCaffinatedCoder library. For reference PR on node-red-contrib-ocpp A docker image containing the changes and a trivial OCPP start flow I hope this helps |
@chrisn-au , I'm trying:
but getting:
|
Ok, the addEventListener callback simply takes an event object as a parameter. So I believe it should be
Let me know how it goes |
Now it's going great! It already reconnects automatically perfectly, the fault was that it did not have to put anything ws.on |
I'm also confused as how to actually use this library. An incredibly basic invocation that I'd expect to work given the docs is: const WS = require("ws");
const ReconnectingWebSocket = require("reconnecting-websocket");
const ws = new ReconnectingWebSocket("wss://<url>/", { WebSocket: WS }); However, this fails with the error in the title. It appears that no matter what,
Unfortunately I'm not really able to dig into this as the compiled JS is horrible to debug and I haven't got anything set up to debug TS, but it appears that EDIT: Nevermind, I'm just dumb. const WS = require("ws");
const ReconnectingWebSocket = require("reconnecting-websocket");
const ws = new ReconnectingWebSocket("wss://<url>/", [], { WebSocket: WS }); |
Good morning,
I am trying to add the reconnect websocket to my code, but the debug of the red node gives me the error "Error: No valid WebSocket class provided"
my code is this:
`const WS = require('ws');
const WebSocket = require('ws');
const uuidv4 = require('uuid/v4');
const events = require('events');
const EventEmitter = events.EventEmitter;
const Logger = require('./utils/logdata');
const debug = require('debug')('anl:ocpp:cp:server:json');
const ReconnectingWebSocket = require('reconnecting-websocket');
let ee = new EventEmitter();
module.exports = function(RED) {
'use strict';
function OCPPChargePointJNode(config) {
RED.nodes.createNode(this, config);
debug('Starting CP client JSON node');
const CALL = 2;
const CALLRESULT = 3;
}
// register our node
RED.nodes.registerType('CP client JSON', OCPPChargePointJNode);
};`
Thank you very much for your possible help
Cheers!
The text was updated successfully, but these errors were encountered: