I built a WebSocket server using WebSocket-Node and the client is an Arduino with an Ethernet shield using the library WebsocketClient from krohling.
The first issue I had was that even the example from the WebsocketClient library didn't return a response from the echo.websocket.org server.
Since the Arduino's Serial monitor didn't give me errors, I added a Serial.print on the handshake section of the library's code to debug the error and I got the following:
HTTP/1.1 400 Bad Request
Server: Kaazing Gateway
Date: Tue, 07 May 2013 05:11:21 GMT
Access-Control-Allow-Origin: ArduinoWebSocketClient
Access-Control-Allow-Credentials: true
Access-Control-Allow-Headers: content-type
Access-Control-Allow-Headers: authorization
Access-Control-Allow-Headers: x-websocket-extensions
Access-Control-Allow-Headers: x-websocket-version
Access-Control-Allow-Headers: x-websocket-protocol
Content-Type: text/html
Content-Length: 63
Connection: Keep-Alive
Then, I tested it with the WebSocket-Node server I created and got the following on the Serial monitor:
HTTP/1.1 400 Bad Request
Connection: close
X-WebSocket-Reject-Reason: Client must provide a value for Sec-WebSocket-Key.
Am I doing something wrong or does the WebsocketClient library need to be updated?
I haven't been lucky to find a better/newer Arduino Websocket client library. Does anyone know about one I could use?
Thanks a lot!
Related
After executing script, in Response Header: connection close message is getting displayed.(As this is the first HTTP Request)
I have recorded a script with the help of HTTP Test Script Recorder.
In the first request, there is no any field captured. But after executing script in Response Header:Connection Close message is displayed.
Response headers:
HTTP/1.1 200 OK
Set-Cookie: BrowserId=vbT9Hz0WSDmhVby-u9ryJQ;Path=/;Domain=.xxxxx.com;Expires=Sat, 13-Apr-2019 08:52:51 GMT;Max-Age=5184000
Strict-Transport-Security: max-age=31536002; includeSubDomains
Public-Key-Pins-Report-Only: pin-sha256="9n0izTnSRF+W4W4JTq51avSXkWhQB8duS2bxVLfzXsY="; pin-sha256="5kJvNEMw0KjrCAu7eXY5HZdvyCS13BbA0VJG1RSP91w="; pin-sha256="njN4rRG+22dNXAi+yb8e3UMypgzPUPHlv4+foULwl1g="; max-age=86400; includeSubDomains; report-uri="https://a.forcesslreports.com/hpkp-report/00Dq0000000DFMbm";
Expect-CT: max-age=0; report-uri="https://a.forcesslreports.com/Expect-CT-report/00Dq0000000DFMbm";
X-Content-Type-Options: nosniff
Content-Security-Policy: upgrade-insecure-requests
X-Robots-Tag: none
Referrer-Policy: origin-when-cross-origin
Cache-Control: no-cache,must-revalidate,max-age=0,no-store,private
Content-Type: text/html; charset=UTF-8
Vary: Accept-Encoding
Connection: close
Content-Encoding: gzip
If you are totally sure that the connection doesn't need to be closed after the first request you can tick Use Keep-Alive box at the HTTP Request sampler level
This way JMeter will send Connection: keep-alive header along with the request hence the connection will not be closed after the request is done (which is more or less in line with what real browsers should be doing - they open a TCP stream and send requests over a single TCP connection)
However your situation might be different, I would recommend capturing the real headers sent by the real browser using browser developers tools or a sniffer tool like Wireshark and make sure JMeter sends the same headers (you can use HTTP Header Manager to add the headers of your choice to the request )
Add a HTTP Cookie Manager to your test plan.
Also, check this quick JMeter Recording guide for getting started
I am getting "Response code 500 - Internal Server Error" for a performance test run in Apache J-Meter 4.0 for a recording of a simple test done over VPN. I am new to this tool and want to know how I can investigate this. As reference, I am mentioning the sampler result error that I am getting.
Sampler Result:
Thread Name: Thread Group 1-1
Sample Start: 2018-06-11 13:21:56 IST
Load time: 1941
Connect Time: 1700
Latency: 1941
Size in bytes: 2301
Sent bytes:2145
Headers size in bytes: 594
Body size in bytes: 1707
Sample Count: 1
Error Count: 1
Data type ("text"|"bin"|""): text
Response code: 500
Response message: Internal Server Error
Response headers:
HTTP/1.1 500 Internal Server Error
Date: Mon, 11 Jun 2018 07:51:58 GMT
Content-Type: text/html; charset=utf-8
Content-Length: 1707
Connection: keep-alive
Set-Cookie: AWSALB=ZS1nnfJyJ+Wk5NEu/FmWGmiRWfEQPnfiywAN8b8f8De6AjOYDrh0nWRVVcsQeBanayjPnpp1IxhjK34EipQB4m/lsAZgdKJ4mgUDDS+Yep8atzWucMNdYTw0oIdB; Expires=Mon, 18 Jun 2018 07:51:58 GMT; Path=/
Access-Control-Allow-Headers: Origin, X-Requested-With, Content-Type, Accept
Access-Control-Allow-Origin: *
Content-Security-Policy: default-src 'self'
Vary: X-HTTP-Method-Override
X-Content-Type-Options: nosniff
X-Powered-By: Express
HTTPSampleResult fields:
ContentType: text/html; charset=utf-8
DataEncoding: utf-8
In the majority of cases you will not be able to successfully replay recorded scenario without modifications.
Add HTTP Cookie Manager to your test plan
Detect all dynamic parameters and perform correlation
Also looking into AWSALB cookie my expectation is that your application under test "hides" behind Amazon Elastic Load Balancer so make sure to add DNS Cache Manager to your Test Plan.
If you still experience problems you can try catching the requests which is being sent by JMeter and by the real browser using a sniffer tool like Wireshark or Fiddler - the requests should be exactly the same (apart from dynamic parameters mentioned in point 2).
I am using JMeter 4.0 for recording & running performance tests. I am also fairly new to this tool and for the 1st time, I'm getting Error 400 Bad request for which all the tests are failing. I am recording a website through VPN & trying it to run the test the same way as I did before.
Can you please help me with this. I can provide additional screenshots and details as & when you say required.
Sampler Result:
Thread Name: Converse_Chat_No 1-1
Sample Start: 2018-06-06 14:29:19 IST
Load time: 1313
Connect Time: 1104
Latency: 1313
Size in bytes: 1639
Sent bytes:1982
Headers size in bytes: 554
Body size in bytes: 1085
Sample Count: 1
Error Count: 1
Data type ("text"|"bin"|""): text
Response code: 400
Response message: Bad Request
Response headers:
HTTP/1.1 400 Bad Request
Date: Wed, 06 Jun 2018 08:59:22 GMT
Content-Type: text/html; charset=utf-8
Content-Length: 1085
Connection: keep-alive
Set-Cookie: AWSALB=hCxbUY5Kq+Vdfv1jhO/JGeLqCqRHT281vZy+T4LFgJCRnItYwGILJLnD3KPsv5wYlVGiy85bYqVH75PSlLNCLcPPDTDtgGHoXAKbw9T8QoT6WPxPm6qVI4tyG7H1; Expires=Wed, 13 Jun 2018 08:59:22 GMT; Path=/
Access-Control-Allow-Headers: Origin, X-Requested-With, Content-Type, Accept
Access-Control-Allow-Origin: *
Content-Security-Policy: default-src 'self'
X-Content-Type-Options: nosniff
X-Powered-By: Express
HTTPSampleResult fields:
ContentType: text/html; charset=utf-8
DataEncoding: utf-8
As per 400 Bad Request description:
The HyperText Transfer Protocol (HTTP) 400 Bad Request response status code indicates that the server could not understand the request due to invalid syntax.
The client should not repeat this request without modification.
So most probably you're sending malformed requests which server doesn't understand.
The only troubleshooting technique I can think of is recording requests which real browser sends using a sniffer tool like Fiddler or Wireshark and comparing them to what JMeter sends. The requests should be the same (apart from dynamic data which has to be correlated)
As soon as you amend your JMeter test plan to 100% match requests which are being sent by the real browser it should start working. Don't forget about Cookies and Headers.
I am using ESP8266-Websocket, aws-sdk-arduino(cleaned branch) and pubsubclient to try to comunicate with aws iot mqtt service using websockets.
My question is about the first connection request. I am using this browser app as reference https://github.com/awslabs/aws-iot-examples and the sign code from aws-sdk-arduino (that works fine calling the aws iot restful api)
My request was this (after connect to the endpoint at 443 port):
GET wss://ENDPOINT.iot.us-west-2.amazonaws.com/mqtt?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AWSKEY%2F20160318%2Fus-west-2%2Fiotdevicegateway%2Faws4_request&X-Amz-Date=20160318T183246Z&X-Amz-Expires=86400&X-Amz-SignedHeaders=host&X-Amz-Signature=a1f0d7b58983f9dff7e3bf6cab062db3243ebafc990803a018c6a23433891404 HTTP/1.1
host: ENDPOINT.iot.us-west-2.amazonaws.com
Connection: Upgrade
Upgrade: websocket
Origin: file://
Sec-WebSocket-Version: 13
Sec-WebSocket-Key: D2alJOyUkBlR+8yhv2UBLg==
Sec-WebSocket-Protocol: mqtt
but I keep getting
HTTP/1.1 403 Forbidden
content-type: application/json
content-length: 241
date: Fri, 18 Mar 2016 18:34:57 GMT
x-amzn-RequestId: f2edfe83-1bbc-4481-97e0-39ccfc4d1c2f
connection: Keep-Alive
x-amzn-ErrorType: ForbiddenException:
am i missing some request header parameter? is there anyway to get a better feedback from x-amzn-ErrorType: ForbiddenException? am i messing up in the sign process? (even though it works for rest call)
Yeah, I've finally got response status 101 switching protocols \o/
when you are building the request, it must be:
GET /mqtt?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AWSKEY%2F20160318%2Fus-west-2%2Fiotdevicegateway%2Faws4_request&X-Amz-Date=20160318T183246Z&X-Amz-Expires=86400&X-Amz-SignedHeaders=host&X-Amz-Signature=a1f0d7b58983f9dff7e3bf6cab062db3243ebafc990803a018c6a23433891404 HTTP/1.1
instead of
GET wss://ENDPOINT.iot.us-west-2.amazonaws.com/mqtt?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AWSKEY%2F20160318%2Fus-west-2%2Fiotdevicegateway%2Faws4_request&X-Amz-Date=20160318T183246Z&X-Amz-Expires=86400&X-Amz-SignedHeaders=host&X-Amz-Signature=a1f0d7b58983f9dff7e3bf6cab062db3243ebafc990803a018c6a23433891404 HTTP/1.1
the js example that I was following was using the full path. When I got the request built by chrome (throught developer tools) the path was full as well. Just after use firebug I got the real request that browser was sending to the server (with short path).
now I can continue to try the solution (mqtt over websockets at esp8266) :-) if it works, I will share the code ;-)
I am setting up apache traffic server as forward proxy and want to push some objects in the cache from out side. I tried following instructions given here.
when I try to push an object following is the output I get
telnet 127.0.0.1 8080
Trying 127.0.0.1...
Connected to 127.0.0.1.
Escape character is '^]'.
PUSH http://www.company.com HTTP/1.0
Content-length: 84
HTTP/1.0 200 OK
Content-type: text/html
Content-length: 17
<HTML>
a
</HTML>
HTTP/1.0 400 Response Not Cachable
Date: Sun, 02 Aug 2015 16:55:41 GMT
Server: ATS/3.2.4
Cache-Control: no-store
Content-Type: text/html
Content-Language: en
Content-Length: 200
<HEAD><TITLE>Response Not Cachable</TITLE></HEAD>
<BODY BGCOLOR="white" FGCOLOR="black">
<FONT FACE="Helvetica,Arial"><B>
</B></FONT>
<!-- default "Response Not Cachable" response (400) -->
</BODY>
Connection closed by foreign host.
Yeah, you have to submit the PUSH request with a correct, cacheable response header. Depending on your ATS settings, that could either be something as simple as a Last-Modified header, or, more likely (ATS defaults) a properly specified Cache-Control: max-age= header.
Edit: Take a look at the traffic_primer script that comes with the ATS source, or from github at https://github.com/apache/trafficserver/blob/master/tools/traffic_primer . It doesn't do exactly what you are asking for, but what it does is to "replay" a request from an origin to other ATS boxes, using PUSH.