HTTP socket connection error

Ritu21
Posts: 112
Joined: Sat Aug 04, 2018 9:58 am

HTTP socket connection error

Postby Ritu21 » Thu Nov 15, 2018 1:05 pm

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.

Ritu21
Posts: 112
Joined: Sat Aug 04, 2018 9:58 am

Re: HTTP socket connection error

Postby Ritu21 » Fri Nov 16, 2018 4:17 am

Please reply.

linuxpaul
Posts: 38
Joined: Thu Jul 20, 2017 6:10 pm

Re: HTTP socket connection error

Postby linuxpaul » Fri Nov 16, 2018 4:24 pm

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

User avatar
fly135
Posts: 606
Joined: Wed Jan 03, 2018 8:33 pm
Location: Orlando, FL

Re: HTTP socket connection error

Postby fly135 » Fri Nov 16, 2018 7:40 pm

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

Ritu21
Posts: 112
Joined: Sat Aug 04, 2018 9:58 am

Re: HTTP socket connection error

Postby Ritu21 » Mon Nov 19, 2018 6:27 am

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.

keesus
Posts: 1
Joined: Thu Mar 14, 2019 8:51 am

Re: HTTP socket connection error

Postby keesus » Fri Mar 15, 2019 3:31 am

@Ritu21

I am having identical problem as yours.

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

thanks.

Ritu21
Posts: 112
Joined: Sat Aug 04, 2018 9:58 am

Re: HTTP socket connection error

Postby Ritu21 » Wed Mar 27, 2019 8:05 am

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.

linuxpaul
Posts: 38
Joined: Thu Jul 20, 2017 6:10 pm

Re: HTTP socket connection error

Postby linuxpaul » Wed Mar 27, 2019 7:23 pm

in my case closing and recreate the socket works.
something like

Code: Select all

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

Ritu21
Posts: 112
Joined: Sat Aug 04, 2018 9:58 am

Re: HTTP socket connection error

Postby Ritu21 » Thu Mar 28, 2019 5:48 am

Your query is related to TCP and this is related to HTTP.

somesh
Posts: 12
Joined: Tue Jun 25, 2019 6:44 am

Re: HTTP socket connection error

Postby somesh » Sat Jul 06, 2019 4:54 pm

Ritu21 wrote:
Thu Mar 28, 2019 5:48 am
Your query is related to TCP and this is related to HTTP.
Hi Ritu21,
I am using both close and cleanup but still I am getting an issue.
Please help me for the same.

Regards,
Somesh Burkule
--
Somesh Burkule

Who is online

Users browsing this forum: Google [Bot], playflash and 12 guests