How do I send Request in Robot Framework It Gives 500 server error - python-3.x

//How do I send Request in Robot Framework It Gives 500 server error
//This is the request body that I want to send
{
"destinationFaxNumber": "9546599326",
"documentCount": 1
}
*** Variables ***
${base_Url}= https://07du47r041.execute-api.us.com/dev/v1/outbound
*** Test Cases ***
Send Fax Request
${headers}= create dictionary Authorization=${Token} Content-Type=application/json
#${file_data}= Get Binary File D:TestCases/SendFax.json //commented
${body}= create dictionary destinationFaxNumber=9546599326 documentCount=1
create session faxsession ${base_Url} headers=${headers}
log to console ${body}
${response}= Post On Session faxsession /fax data=${body} headers=${headers}
However I'm getting below error
HTTP Error: 500 Server Error: Internal Server Error for url: https://07du47r041.execute-api.us.com/dev/v1/outbound/fax

If postman works and RF does not, the request payload is 99.99% at fault. Capture network traffic with succesful and failing requests and compare what is different.
For example, if you have access to linux box or any machine with netcat, start nc on some port and point the url from postman and rf into that NC socket and see the request differences right in the console of nc.

Related

.NetCore gRPC client is not able to call Node with NestJs gRPC Server

We have a gRPC server in NodeJs with Nest running on separate port 3001, and when we call this from the Node client it works fine. But one of our microservice is in.NETCore when we try to call it gives us the below error. Currently, we are stuck at the 3,4 point. if someone can guide us it will be very helpful.
1. Status(StatusCode="Unimplemented", Detail="The server does not implement the method", ResponseCode: "404")
2. Status(StatusCode="Internal", Detail="Bad gRPC response. Response protocol downgraded to HTTP/1.1.")
3. An error occurred while sending the request. Http2ConnectionException: The HTTP/2 server sent invalid data on the connection. HTTP/2 error code 'PROTOCOL_ERROR' (0x1).
4. An error occurred while sending the request. IOException: The request was aborted. Http2ConnectionException: The HTTP/2 server sent invalid data on the connection. HTTP/2 error code 'PROTOCOL_ERROR' (0x1).
What we have tried,
AppContext.SetSwitch("System.Net.Http.SocketsHttpHandler.Http2UnencryptedSupport", true);
On startup we use the Kestrel with listening to Http1,
options.ListenLocalhost(5000, o => o.Protocols = HttpProtocols.Http1);
Added HttpClientHandler configuration for certificate and SslProtocols

Terminating file upload to NodeJS backend causes Apache 502 Gateway Error

I've got an Apache webserver proxying some requests to a NodeJS backend. When the user uploads a invalid file, my server terminates the request with an error message. While this works correctly when calling the NodeJS backend directly, a 502 Bad Gateway error ("The proxy server received an invalid response from an upstream server.
") is given when proxied through Apache.
The NodeJS termination (req = request, res = response)
req.pause()
res.statusCode = 400
res.setHeader('Content-Type', 'text/plain');
res.end("Invalid Request: " + e.message);
req.destroy(["Invalid Request: " + e.message])
I'd like to immediately end the upload (to save time & bandwidth), and send an error message to the client, so simply pausing the request doesn't work for me - it leaves the client hanging. Not setting "Connection: close" or destroying the socket causes upload to continue, even after res.end is called with the error message.
I am seeing an "http error before end of send, stop sending" error in Apache, so it's pretty clear that Apache is treating this as a backend server fault, rather than a legitimate error message to be returned to the client. How do I fix this? I've done quite a bit of searching, but haven't found a clear answer.
The current proxy code (not much):
ProxyPass /node http://127.0.0.1:3000/node
More code can be provided upon request.

socket.io client doesn't set sid in requests

I'm trying to build a nodejs script to communicate with a socket.io server.
const io = require('socket.io-client');
const socket = io('http://192.168.144.249');
socket.on('connect', () => {
console.log('connected');
})
Using wireshark to follow traffic I can see the following:
So the browser sends me a sid, both in the response body and in the cookie.
Unfortunately, my following requests do not include this sid and I received a 400 Bad Request error:
When I try to build the same client from a browser windows I can see that this cookie is indeed set, both as cookie and as a query parameter:
I don't want to use a browser, I want to use a standalone node script. As far as I understood the parsing of the response and the inclusion of the session id should be done automatically by the socket.io-client. Am I wrong? If so, how can I intercept this event so that I can send the sid with following requests?
Am I supposed to first do a simple http request to the server, get the sid from there and then add it to the socket.io client when creating it using custom cookies or custom query parameters?
I can also see that the node standalone script is using engine.io version 4 (EIO=4 in the GET requests), while the browser is doing it with engine.io version 3, but the respose received seems to be exactly the same so I don't really think this is what is preventing my script from automatically completing the handshake with the server.
Well, I was wrong. It was indeed a protocol mismatch problem.
I was able to make my script working using socket.io-client#1.0.2. Install it with:
npm install socket.io-client#1.0.2

Can you send a message to a websocket client from a non-websocket lambda?

I have a nodejs websocket AWS lambda endpoint (Api Gateway) set up and it connects and can echo messages back. During initial connection, I save the endpoint and connection_id to a database. That gets saved just fine. If I open a browser client, and connect to the websocket endpoint, I can connect successfully, and send a message from the browser successfully - I have code to echo the message back, and it works.
Now, in another nodejs lambda, one that provides a REST endpoint, I have code that loads the connection_id from the database and does this:
// 'connection' is loaded successfully from DB (I log it and see the right values)
let api = new AWSSDK.ApiGatewayManagementApi({apiVersion: '2018-11-29', endpoint: connection.endpoint});
await api.postToConnection({
ConnectionId: connection.connection_id,
Data: JSON.stringify({ message: 'Hello World' })
}).promise();
However, the code in the REST endpoint (code above) always gets a 410 error in the postToConnection. I know the connection is still active, since I can connect to it and ping it in a browser client just prior to testing the REST API above.
Is it not possible to post to a websocket connection from a non-websocket lambda?
I think you should use this to send messages from the backend to your clients.
To send a callback message to the client, use:
POST
https://{api-id}.execute-api.us-east-1.amazonaws.com/{stage}/#connections/{connection_id}
https://docs.aws.amazon.com/apigateway/latest/developerguide/apigateway-how-to-call-websocket-api-connections.html

How can i get invalid request message from client in node js http module

As i asked,
I just want to know how to get invalid message from client in nodejs http server.
For example, normally client send "GET / HTTP/1.1\r\n\r\n" to server, But if i sent "VID / HTTP/1.1\r\n\r\n" like this, there is no react in server. I already checked that server computer gets "VID / HTTP/1.1\r\n\r\n" message using wire-shark.
Thank you for your help.
I looked the solution that using 404 response, But It not worked.
look at this server creation code
function server(Route,connect){
console.log("start server function");
function onRequest(req, response) { //req:clientrequest ,response : server response;
console.log("ans server");
Route(req,connect,response,hnd.Hnd);
}
http.createServer(onRequest).listen(port);
}
when I send message "GET /HTTP/1.1\r\n\r\n" from client, server console write "ans server". But not VID
VID is one kind of example that I assume protocol..
#slebetman : Thank you for your solution.
I've voted to close and link it to the appropriate question (see above). Unfortunately, you'll have to modify node in C and compile your own custom node.js. There have been requests for adding an API for this but so far it looks like it's not going anywhere: github.com/joyent/node/issues/3192 and github.com/joyent/http-parser/pull/158 – slebetman

Resources