Closed sergeushenecz closed 2 years ago
@sergeu90, you must take into account that socket.write()
is asynchronous, so, in your code, socket.destroy()
might be called first. This will destroy the socket and then try to write to it. That's why you get that error.
A workaround would be to use the callback provided by socket.write()
to make sure you destroy the socket after writing.
@Rapsssito Thanks a lot for helping. It is working.
client.write(data, null, () => {
client.destroy();
});
Glad it worked! I will close the issue now.
Description
When I click for the first time everything is fine. Sometimes I click a second time and it's also good, but there is such a random error
Steps to reproduce
Steps to reproduce the behavior:
Current behavior
I have print btn. Attempt to invoke virtual method 'java.io.OutputStream' java.net.Socket.getOutputStream on a null object reference.
Expected behavior
Code to need works.
Screenshots
Relevant information