We see error "Error: Unexpected server response: 502" when update to version 0.1.3
lehongvo opened this issue · comments
[ERROR]: ErrorEvent {
[Symbol(kTarget)]: WebSocket {
_events: [Object: null prototype] {
open: [Function],
error: [Function],
message: [Function],
close: [Function]
},
_eventsCount: 4,
_maxListeners: undefined,
_binaryType: 'arraybuffer',
_closeCode: 1006,
_closeFrameReceived: false,
_closeFrameSent: false,
_closeMessage: <Buffer >,
_closeTimer: null,
_extensions: {},
_paused: false,
_protocol: '',
_readyState: 2,
_receiver: null,
_sender: null,
_socket: null,
_bufferedAmount: 0,
_isServer: false,
_redirects: 0,
_url: 'wss://testnets-stream.openseabeta.com/socket/websocket?token=cddad7a1687e4e02bdf9164c7e9e3706&vsn=2.0.0',
_req: ClientRequest {
_events: [Object: null prototype],
_eventsCount: 4,
_maxListeners: undefined,
outputData: [],
outputSize: 0,
writable: true,
destroyed: true,
_last: true,
chunkedEncoding: false,
shouldKeepAlive: true,
maxRequestsOnConnectionReached: false,
_defaultKeepAlive: true,
useChunkedEncodingByDefault: false,
sendDate: false,
_removedConnection: false,
_removedContLen: false,
_removedTE: false,
strictContentLength: false,
_contentLength: 0,
_hasBody: true,
_trailer: '',
finished: true,
_headerSent: true,
_closed: false,
_header: 'GET /socket/websocket?token=cddad7a1687e4e02bdf9164c7e9e3706&vsn=2.0.0 HTTP/1.1\r\n' +
'Sec-WebSocket-Version: 13\r\n' +
'Sec-WebSocket-Key: VljI3//PEXcPL2o2o2nj7w==\r\n' +
'Connection: Upgrade\r\n' +
'Upgrade: websocket\r\n' +
'Sec-WebSocket-Extensions: permessage-deflate; client_max_window_bits\r\n' +
'Host: testnets-stream.openseabeta.com\r\n' +
'\r\n',
_keepAliveTimeout: 0,
_onPendingData: [Function: nop],
agent: undefined,
socketPath: undefined,
method: 'GET',
maxHeaderSize: undefined,
insecureHTTPParser: undefined,
joinDuplicateHeaders: undefined,
path: '/socket/websocket?token=cddad7a1687e4e02bdf9164c7e9e3706&vsn=2.0.0',
_ended: false,
res: [IncomingMessage],
aborted: true,
timeoutCb: null,
upgradeOrConnect: false,
parser: [HTTPParser],
maxHeadersCount: null,
reusedSocket: false,
host: 'testnets-stream.openseabeta.com',
protocol: 'https:',
[Symbol(kCapture)]: false,
[Symbol(kBytesWritten)]: 0,
[Symbol(kNeedDrain)]: false,
[Symbol(corked)]: 0,
[Symbol(kChunkedBuffer)]: [],
[Symbol(kChunkedLength)]: 0,
[Symbol(kSocket)]: [TLSSocket],
[Symbol(kOutHeaders)]: [Object: null prototype],
[Symbol(errored)]: null,
[Symbol(kHighWaterMark)]: 16384,
[Symbol(kRejectNonStandardBodyWrites)]: false,
[Symbol(kUniqueHeaders)]: null,
[Symbol(kAborted)]: true,
[Symbol(kError)]: undefined
},
timeout: 20000,
[Symbol(kCapture)]: false
},
[Symbol(kType)]: 'error',
[Symbol(kError)]: Error: Unexpected server response: 502
at ClientRequest.<anonymous> (/Users/nguyenductrang/Desktop/Contract/BAP/Javis/smart-contract/node_modules/ws/lib/websocket.js:896:7)
at ClientRequest.emit (node:events:515:28)
at HTTPParser.parserOnIncomingClient [as onIncoming] (node:_http_client:693:27)
at HTTPParser.parserOnHeadersComplete (node:_http_common:119:17)
at TLSSocket.socketOnData (node:_http_client:535:22)
at TLSSocket.emit (node:events:515:28)
at addChunk (node:internal/streams/readable:545:12)
at readableAddChunkPushByteMode (node:internal/streams/readable:495:3)
at Readable.push (node:internal/streams/readable:375:5)
at TLSWrap.onStreamRead (node:internal/stream_base_commons:190:23),
[Symbol(kMessage)]: 'Unexpected server response: 502'
}
My COde
const { OpenSeaStreamClient, Network, EventType } = require('@opensea/stream-js');
const { WebSocket } = require('ws');
const scanDataNFT = async () => {
try {
const client = new OpenSeaStreamClient({
token: 'cddad7a1687e4e02bdf9164c7e9e3706',
network: Network.TESTNET,
connectOptions: {
transport: WebSocket
}
});
client.connect();
const collectionSlug = "creaturesnft-37";
client.onEvents(
collectionSlug,
[
EventType.ITEM_METADATA_UPDATED,
EventType.ITEM_CANCELLED,
EventType.ITEM_LISTED,
EventType.ITEM_SOLD,
EventType.ITEM_TRANSFERRED,
EventType.ITEM_RECEIVED_OFFER,
EventType.ITEM_RECEIVED_BID,
EventType.COLLECTION_OFFER,
EventType.TRAIT_OFFER,
EventType.ORDER_INVALIDATE,
EventType.ORDER_REVALIDATE,
],
(event) => {
console.log("event", event)
}
);
} catch (error) {
console.log(error);
}
}
scanDataNFT()
HI @ryanio, We see error "Error: Unexpected server response: 502". I thing your serve Die, please check your serve
@ryanio PLease check my issue, My error same with @Christophy
gm, I have exactly the same issue<
Thanks for the help
Getting regular 502's here as well. It automatically tries to reconnect, fails a few times but then it's able to connect to the stream again. v0.1.3.
I managed to solve the issue by not putting 2 collections in the same request. Now I separate each collection and the problem disappear.
Getting similar 503 error with testnet endpoint. Works A-OK with mainnet.
Thanks for letting us know, we are looking into fixing testnets
this should be fixed now! if you are still experiencing issues please open a new issue with steps to reproduce.