liamcottle / rustplus.js

Unofficial NodeJS library for controlling Smart Switches in the PC game Rust
228 stars 46 forks source link

getting websocket Parse Error: expected HTTP/ as a response after several successful requests #14

Closed jh0l closed 3 years ago

jh0l commented 3 years ago

I get this error in NodeJS console when sending requests through the RustPlus.sendRequest method

Error: Parse Error: Expected HTTP/
    at Socket.socketOnData (_http_client.js:509:22)
    at Socket.emit (events.js:315:20)
    at addChunk (internal/streams/readable.js:309:12)
    at readableAddChunk (internal/streams/readable.js:284:9)
    at Socket.Readable.push (internal/streams/readable.js:223:10)
    at TCP.onStreamRead (internal/stream_base_commons.js:188:23) {
  bytesParsed: 0,
  code: 'HPE_INVALID_CONSTANT',
  reason: 'Expected HTTP/',
  rawPacket: <Buffer 88 02 03 e8>
}
Error: Parse Error: Expected HTTP/
    at Socket.socketOnData (_http_client.js:509:22)
    at Socket.emit (events.js:315:20)
    at addChunk (internal/streams/readable.js:309:12)
    at readableAddChunk (internal/streams/readable.js:284:9)
    at Socket.Readable.push (internal/streams/readable.js:223:10)
    at TCP.onStreamRead (internal/stream_base_commons.js:188:23) {
  bytesParsed: 0,
  code: 'HPE_INVALID_CONSTANT',
  reason: 'Expected HTTP/',
  rawPacket: <Buffer 88 02 03 e8>
}

But this does not happen on the first request, only after several requests have been successful already. Is this some sort of throttling message from the rust game server that cannot be read as a HTTP response?

liamcottle commented 3 years ago

I'm not too sure on this one sorry. Let me know if you're able to find a fix.