Closed XXuain closed 2 years ago
Hi, I have a question is when I use new WebSocket(URL), I can find the CloseEvent and code or reason information in that CloseEvent. Like this:
new WebSocket(URL)
CloseEvent
code
reason
export const connectSocket = () => { socket = new WebSocket(wsUrl); socket.onerror = function (err) { console.log('error >> ', err); }; socket.onclose = function (e) { console.log('onclose >> ', e); }; };
But, how can I use SubscriptionClient to find somthing like CloseEvent have code and reason information There is what I try.
SubscriptionClient
import { SubscriptionClient } from 'subscriptions-transport-ws'; import { WebSocketLink } from '@apollo/client/link/ws'; export const wsClient = new SubscriptionClient(WS_URI, { reconnect: true }); const wsLink = new WebSocketLink(wsClient); wsClient.onError((error) => console.log('onError---', error)); wsClient.onConnected((info) => console.log('onConnected---', info)); wsClient.close((info) => console.log('onConnected---', info)); wsClient.onReconnected((info) => console.log('onReconnected---', info)); wsClient.onDisconnected((info) => console.log('onDisconnected---', info));
Above console only onError have display infomation, others display undefined 0.0
onError
Hi, I have a question is when I use
new WebSocket(URL)
, I can find theCloseEvent
andcode
orreason
information in that CloseEvent. Like this:But, how can I use
SubscriptionClient
to find somthing likeCloseEvent
havecode
andreason
information There is what I try.Above console only
onError
have display infomation, others display undefined 0.0