I connect websocket to my client app (this is include websocket server and this is electron application) and my plugin is used by websocket client.
I want to know error when occur error of websocket through ‘onerror’ event handler
but, parameter of onerror handler is always empty object ‘{}’
my error handler code is like below:
ws.onerror = function(err: any): any {
console.log('error', err, err.message); // It displayed '{} undefined'
console.log('error', err.error, err.lineno, err.filename, err.colno, err.message); // It displayed '{} undefined undefined undefined, undefined'
}
and research about Websocket error handler from MDN(https://developer.mozilla.org/en-US/docs/Web/API/WebSocket/onerror)
I cannot find any useful information.
anyone who knows about this issue, please comment for me. thx
I’ve allowed myself to give your code some formatting so it’s easier for us to read, understand and help . I hope you don’t mind…
For future reference: Posts gets formatted as Markdown, so that you can format a block of code like this:
resulting in something like this:
// my code
This makes the code easily readable and everyone much more willing to help
Hi @pyeong.oh,
first of all: welcome to the forums . You might want to consider writing a short introduction in the introductions category .
According to the WebSocket
docs, XD’s APIs don’t have a WebSocket::onerror
handler. Since your console.log
statements seem to execute, this seems to be an undocumented aspect of the APIs, meaning it’s probably incomplete and subject to change. I would therefore be very careful about using it at all.
I unfortunately don’t know a solution to your problem, but as a quick response, please be aware that there are aspects of the plugin APIs that aren’t on par with – say – standard web APIs. Therefore, you’ll probably have to use something else here, as onerror
is, in a way, uncharted territory in the plugin APIs .
HI, Nothing problem, I’m rather grateful for modify my post to improve readability.
I will try to write the post in the correct format next time.
1 Like
Ah, That is exactly what i wondering of. thx
1 Like
if any other solution to handling error when use XD’s websocket API?
1 Like