How to detect if transport connection break

84 views
Skip to first unread message

Afriyie Abraham Kwabena

unread,
Nov 20, 2020, 3:51:21 AM11/20/20
to golang-nuts

Hi,

My basic understanding of HTTP protocol is that an HTTP client sent request, get response from the HTTP server and then the connection is closed.

My question is how can an HTTP client detect if the underling transport connection break. For example if the HTTP server shutdown, is there a way to detect that at the client so that the client can start a persistent request.

If possible, how can I do that in golang HTTP client?

BR
Abraham


Amit Saha

unread,
Nov 20, 2020, 4:41:42 AM11/20/20
to Afriyie Abraham Kwabena, golang-nuts
Are you thinking about implementing a connection pool for your long lived process?



BR
Abraham


--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/4937b529-c1aa-4425-8b81-01214c1fc1f7n%40googlegroups.com.

Afriyie Abraham Kwabena

unread,
Nov 20, 2020, 6:07:12 AM11/20/20
to golang-nuts
Hi,

Am new to programming and if you could explain further what you mean by long lived process.

Afriyie Abraham Kwabena

unread,
Nov 20, 2020, 10:12:09 AM11/20/20
to golang-nuts
Hi,

Yes, that is what intend to implement. Can you help with some information about how
I could implement it.
If possible some libraries or example code.

Abraham

Amit Saha

unread,
Nov 20, 2020, 3:56:17 PM11/20/20
to Afriyie Abraham Kwabena, golang-nuts
On Sat, 21 Nov 2020, 2:12 am Afriyie Abraham Kwabena, <afriyie...@gmail.com> wrote:
Hi,

Yes, that is what intend to implement. Can you help with some information about how
I could implement it.
If possible some libraries or example code.

The standard library's http client as defined in net/http uses a transport layer connection pool already. I believe it will take care of the scenario you are trying to solve. 

This issue https://github.com/golang/go/issues/23427 has some relevant discussions and starting points for you to explore more. I also recommend looking at this post https://blog.golang.org/http-tracing for further research


Abraham

On Friday, November 20, 2020 at 1:07:12 PM UTC+2 Afriyie Abraham Kwabena wrote:
Hi,

Am new to programming and if you could explain further what you mean by long lived process.
 

On Friday, November 20, 2020 at 11:41:42 AM UTC+2 amits...@gmail.com wrote:


On Fri, 20 Nov 2020, 7:51 pm Afriyie Abraham Kwabena, <afriyie...@gmail.com> wrote:

Hi,

My basic understanding of HTTP protocol is that an HTTP client sent request, get response from the HTTP server and then the connection is closed.

My question is how can an HTTP client detect if the underling transport connection break. For example if the HTTP server shutdown, is there a way to detect that at the client so that the client can start a persistent request.

If possible, how can I do that in golang HTTP client?

Are you thinking about implementing a connection pool for your long lived process?



BR
Abraham


--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/4937b529-c1aa-4425-8b81-01214c1fc1f7n%40googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages