Skip to content

Commit b86fec4

Browse files
committed
fix Server sent no subprotocol error
1 parent c433ba2 commit b86fec4

2 files changed

Lines changed: 5 additions & 1 deletion

File tree

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,9 @@ Of course I'm also very glad about issues and pull requests if you find a bug /
173173
Placeholder for next versions (this needs to be indented):
174174
### __WORK IN PROGRESS__
175175
-->
176+
### __WORK IN PROGRESS__
177+
* fix 'Server sent no subprotocol' error and ignore ts warnings.
178+
176179
### 0.5.3 (2023-04-28)
177180
* fix d.ts
178181

index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,8 @@ class WebSocketClient extends EventEmitter.EventEmitter {
9696
connect() {
9797
let resolved = false;
9898
return new Promise((resolve, reject) => {
99-
this._device.socket = new WebSocket('wss://' + this._device.ip + ':' + this._device.port + '/SwitchCamera', ['13'], {
99+
this._device.socket = new WebSocket('wss://' + this._device.ip + ':' + this._device.port + '/SwitchCamera', {
100+
// @ts-ignore -> we need to ignore here, because we must not set subprotocols, server does not set subprotocols, so we can't either or we get an error "Server sent no subprotocol" and connection is closed by ws. The code currently accepts omitting the subprotocols this way, even if the type definitions don't allow it.
100101
rejectUnauthorized: false,
101102
timeout: 5000
102103
});

0 commit comments

Comments
 (0)