Process Golang HTTP requests if client closes the connection or cancel requests - http

Problem Statement:
Whenever Customer closes browser or client closes connection , golang mux HTTP handler cancels the requests with context cancelled error.
Expectation:
On certain routes if customer closes browser or drops off, we want to process requests and do not want to cancel the request.

Related

How are Server-Sent Events supposed to be used in a "update list" scenario?

What I want to achieve is the following:
There is a list of things and the server wants to notify the client about changes to that list.
Which of the following setups are recommended and why:
I send an SSE request from the client to the server and the server sends updates of the list in an event. The server doesn't close the connection, it is closed when client leaves the page the list is on.
I send an SSE request from the client to server. The server sends an event when the list is updated, then closed the connection. The client then (after processing the event) sends a new request to the server, waiting for another event from the server.

Mule 3 : http listener persistent connections and Connection Idle timeout

I am new to Mule and trying to learn Mule 3 (some of our existing API in production are using Mule 3).
A production application has an HTTPlistener using 'use Persistent connection' and 'connection idle timeout' as default value of 30000 (30 seconds).
My understanding i that if I call the API that listens to the request at this listener from Postman (the REST client), if the request takes more than 30 seconds, it should receive a timeOut error (504).
We added a Thread.sleep in an expression to simulate this behavior.
<expression-component doc:name="Expression"><![CDATA[Thread.sleep(60000);]]></expression-component>
This will cause the sleep to wait for 1 minute, which is greater than 30 seconds configured for a timeout.
However, the request waits for the thread to wake up after 1 minute and returns a successful response.
So I am not sure what is the purpose of 'connection idle timeout' ?
Also, what does 'persistent connection' mean ?
The documentation is vague.
HTTP Persistent Connections are a feature of the HTTP protocol, that the connector implements. The connection idle time indicates how long the persistent connection will remain open if there is no activity. It is not related to a response timeout, that is a timeout on the client side and seems to be what you are expecting. In this case the HTTP Listener is the server and Postman is the client.
A response timeout in the client doesn't has an HTTP status response because the request is aborted. You can get a 504 status if the request is against a proxy and the proxy has a client timeout against a backend. The proxy usually returns a 504 in that scenario.
The documentation for connectors assumes that you are familiar with the protocol or backend concepts. In this case the HTTP protocol.

Client Not loading Webpage

Setup
180.87.13.77 ===Router=========GRE TUNNEL=========ROUTER=====Internet===Webserver
The client .77 cannot open few web sites.
We did a packet capture and noticed in all the TCP sessions
after HTTP GET is requested, Server is Sending RST/ACK
THis terminate the session.
No idea on what is happening.Wireshark Capture

Netty Client sending Keep Alive HTTP request

I am creating a Netty Client which sends HTTP request to POST data to server.To increase the performance what i did was using Keep alive Http request(i know that in HTTP 1.1 all requests are keep alive by default, so i am making sure that Connection header is not set to close while sending the Http request) so that it uses the same channel to send the Http Request. Now when i send the Http request to the correct URL,i.e. if i get HttpResponse Status OK in return from server, i am able to send the next Http Request properly but when i send the Http Request for which i get BAD REQUEST or SERVICE UNAVAILABLE or something other than OK then i am unable to send the next request that is the channel future f.success() returned after calling channel.write(request) is false. I am unable to understand why it happens. I have followed the same model of coding as done in HttpSnoopClient example given in netty,
except i have removed the connection:close header & even the client handler is the same as that given in snoop client, also i have am instantiating the bootstrap only once at the starting
I tried getting channelFuture f.cause().getMessage() but it was null it seems

Doubt in browser server interaction

Suppose I click on a link to website A on a page and just before the current page gets replaced, I click on a different link to a different website say B.
What happens to the request that was sent to website A? Does the webserver of site A reply back and the browser just rejects the HTTP reply?
There is no specific HTTP provision for canceling a request. I would expect this to happen at the socket level.
I would expect the associated TCP socket to be closed immediately upon canceling the request. Since http uses only 1 socket, the server will get the close after the request. If the close was processed before the data is generated, generated data down won't be sent to the client. Otherwise the data is sent to the client and ignored since the socket is closed. There may be wasted work, but a special http message to "cancel" would have the same effect.

Resources