Page 1 of 1

HTTP socket connection error

Posted: Thu Nov 15, 2018 1:05 pm
by Ritu21
Hi,

I am using http_client to send UART data to http_server. Data is received & I get the below response.

I (58813) http_client: HTTP POST Status = 201, content_length = -1

But, it happens till 8 times the data is received on UART, after which (i.e. 9th time) I start getting the below error till I reboot the module.

E (64173) TRANS_TCP: Error create socket
E (64173) HTTP_CLIENT: Connection failed, sock < 0
E (64183) http_client: HTTP POST request failed: ESP_ERR_HTTP_CONNECT

Is there any limit to socket creation ?? Please help me to rectify this.

Thanks
R.

Re: HTTP socket connection error

Posted: Fri Nov 16, 2018 4:17 am
by Ritu21
Please reply.

Re: HTTP socket connection error

Posted: Fri Nov 16, 2018 4:24 pm
by linuxpaul
Hi,

I'm not very familar with writing code and I'm not sure I got this question.
I don't think that the number of sockets is limited in that number but
I can't get the connection from one UART to the need of multible sockets.

my experience:
I wrote this socket uart bridge:
https://bitbucket.org/linuxpaul/esp32-u ... rc/master/

Multible sockets on a client?
Sometimes there is some trouble with a socket e.g. the connection hat changed.
So I need a close and a reinit. Somtimes the reinit fails because the LAN connection or
wifi has been dropped then I do a wifi reinit. In the result I think there is no more then on open
socket on my Module.

Multible sockets on a Server?
In my opinion this is possible but just multible clients are connected, or?

... but may be I'm totally wrong
:) linuxpaul

Re: HTTP socket connection error

Posted: Fri Nov 16, 2018 7:40 pm
by fly135
Ritu21 wrote:
Fri Nov 16, 2018 4:17 am
Please reply.
After reviewing the code you posted I'm going to take a wild guess and say... "You're doing something wrong".

Yes, there is a limit to how many sockets you can have created at the same time. Just like there is a limit to how much memory you can allocate at once.

John A

Re: HTTP socket connection error

Posted: Mon Nov 19, 2018 6:27 am
by Ritu21
Hi,

Yes, I was not closing the connection and that's why I was getting the error.

Now I am sorted with that problem.

Thank you for your time.

Regards
R.

Re: HTTP socket connection error

Posted: Fri Mar 15, 2019 3:31 am
by keesus
@Ritu21

I am having identical problem as yours.

Could you inform me how did you solve this problem in details?

thanks.

Re: HTTP socket connection error

Posted: Wed Mar 27, 2019 8:05 am
by Ritu21
Hi Keesus,

Sorry for my delay in response.

You should always close the connection after sending data to the server by using below api's.

esp_http_client_close(client);
esp_http_client_cleanup(client);

Let me know if you get rid of this problem with the solution..

Thanks
R.

Re: HTTP socket connection error

Posted: Wed Mar 27, 2019 7:23 pm
by linuxpaul
in my case closing and recreate the socket works.
something like

Code: Select all

close(clientSock)
...
clientSock = accept(sock, (struct sockaddr *)&clientAddress, &clientAddressLength);

Re: HTTP socket connection error

Posted: Thu Mar 28, 2019 5:48 am
by Ritu21
Your query is related to TCP and this is related to HTTP.