Search code examples
tcpjmeterlogstash

HTTP Raw request default is throwing Response message:java.net.SocketTimeoutException: Timeout exceeded while reading from socket


I sent a HTTP Raw request default with a host and port which I'm certain that I could connect using my windows 10 device.(Tested with Test-NetConnection and sent data via Ubuntu App, echo "DEMO Message" | nc mYHOST 6021) However, when I sent the request in Jmeter , I get below errors.

Sampler result is as per the below.

Thread Name:Thread Group 1-1
Sample Start:2021-09-17 15:55:08 IST
Load time:9300
Connect Time:0
Latency:0
Size in bytes:921
Sent bytes:0
Headers size in bytes:0
Body size in bytes:921
Sample Count:1
Error Count:1
Data type ("text"|"bin"|""):text
Response code:500
Response message:java.net.SocketTimeoutException: Timeout exceeded while reading from socket


SampleResult fields:
ContentType: 
DataEncoding: null

Response is as per the below.

java.net.SocketTimeoutException: Timeout exceeded while reading from socket
java.net.SocketTimeoutException: Timeout exceeded while reading from socket
    at kg.apc.io.SocketChannelWithTimeouts.read(SocketChannelWithTimeouts.java:133)
    at kg.apc.jmeter.samplers.HTTPRawSampler.readResponse(HTTPRawSampler.java:64)
    at kg.apc.jmeter.samplers.HTTPRawSampler.processIO(HTTPRawSampler.java:163)
    at kg.apc.jmeter.samplers.AbstractIPSampler.sample(AbstractIPSampler.java:112)
    at kg.apc.jmeter.samplers.HTTPRawSampler.sample(HTTPRawSampler.java:42)
    at org.apache.jmeter.threads.JMeterThread.doSampling(JMeterThread.java:630)
    at org.apache.jmeter.threads.JMeterThread.executeSamplePackage(JMeterThread.java:558)
    at org.apache.jmeter.threads.JMeterThread.processSampler(JMeterThread.java:489)
    at org.apache.jmeter.threads.JMeterThread.run(JMeterThread.java:256)
    at java.base/java.lang.Thread.run(Thread.java:830)

This demo host and port is working though and I used exact same in my real request too. enter image description here

Similar issues come when I use JSR223 Sampler with below code.

def client = new Socket('DemoHostname', 9000);
client.setSoTimeout(2000);
client << "Hello ";
client.withStreams { input, output ->
    def reader = input.newReader()
    def response = reader.readLine()
    log.info('Response = ' + response)
}
client.close() 

Also with TCP Sampler of Jmter.

So based on the suggestion, I sent it as a Http request to websocket of Logstash. Good thing is add the record get added, but Jmter http request is running in an endless state. Seems since logstash communicate via TCP it's unable to provide a http response.

enter image description here


Solution

  • What are you trying to achieve by sending HELLO TEST to echo.websocket.org?

    If you want to send a HTTP Request there, you need to do something like:

    GET / HTTP/1.1
    Host: echo.websocket.org
    Connection: close
    

    Demo:

    enter image description here

    If you need to load test a WebSocket server - you're using the wrong plugin, you should go for JMeter WebSocket Samplers instead and consider using more "alive" endpoint as this echo.websocket.org doesn't seem to be working anymore.