Sockettimeoutexception
Solution 1:
Your socket is timing out means that it takes too long to get respond from other device and your request expires before getting response.To tackle this you need to give manual socket timeout like search for how to provide socket timeout of the library you are using. If using socket.io then you need to add
socket.timeout(12000);
Here 12000 are milli seconds or if you are using OkHttp Client then you can add:
clientBuilder.connectTimeout(60, TimeUnit.SECONDS);
Or whichever socket library you are using there is method to give timeout manually so just type your socket name with which you created socket and place '.' after that you have suggestions for available methods in that search for timeout and use that method.
Here is the link use that library demo is also there:
Solution 2:
I had same problem but I fix it by using these approaches
Set Character Encoding to UTF-8 and charset
Solution 3:
Although I'm not entirely sure, I don't think you're using Socket.setSoTimeout()
correctly.
You're only supposed to use it once for the Socket requestSocket. Try having it at the beginning of your code before you work with the contents of the Socket, or make your code modular by passing it to a function instead of calling the function thrice. That makes it heaps easier to work with Socket.setSoTimeout()
from my personal experience.
Solution 4:
I show you code you have pasted.
I found you set time 3000ms on line no 117 and 125 for timeout you need to change it maximum up to 15 second
requestSocket.connect(newInetSocketAddress(a,6666),3000);
Hope its help
Happy Coding.!
Post a Comment for "Sockettimeoutexception"