Connection drops when sending data over TCP

General discussion on mikroPascal PRO for PIC32.
Post Reply
Author
Message
VCC
Posts: 463
Joined: 08 Jun 2009 18:31
Location: Romania

Connection drops when sending data over TCP

#1 Post by VCC » 28 Jun 2020 09:31

Hi,
I am working on a client-server application which sends files from a desktop (Windows or Linux) client to a PIC32 server. The approach was to use a permanent connection to the server, instead of using http PUT requests. I don't plan on implementing a webserver. I am using Network Ethernet Library (internal) on PIC32MX795F512L (the mikromedia Plus for PIC32MX7 board). Clients can connect, send files to the PIC, but from time to time, the connection drops in the middle of a file transfer. It can be reproduced by sending files of several MB in size. I have tested it on small local networks, to get an acceptable latency, both from Windows to board and Linux to board, with the same results. Also tested with three different routers.
At the moment, I tend to blame the Network Ethernet Library (or maybe the lack of enough documentation about it), because implementing the same protocol on a desktop server, gives the proper results. The protocol is simple: the server (PIC32) expects a command (e.g. file transfer), then reads chunks of the transferred file and confirms every chunk back to the client. Somewhere in between these responses, the connection drops. When that happens, what's interesting is that Wireshark confirms the sending of packets, but somehow they never make it to the application. It displays them as spurious transmission, which means (if I'm not wrong) sending again already acknowledged packets. I didn't encounter this behavior using a PC server, only the PIC32 server.

Has anybody managed to do a proper file transfer to a PIC32 server using the Network Ethernet Library?

The code is available on Libstock: https://libstock.mikroe.com/projects/vi ... fer-to-pic It also contains a server application, to confirm the connection or protocol.
Both desktop applications (client and server) are written in FreePascal (the CodeTyphon edition, because it already comes with Indy). The PIC32 server is written in mikroPascal PRO for PIC32 v4.0.0.

The provided example uses 1024B sized chunks when sending the file, but it seems that this is unrelated to the problem, as the connection drops even for smaller chunks. Maybe it's a bug in my code or something, but chunks bigger than 1024 seem to fail all the time, although the receiving buffer should accept 2048B chunks (or even 4096B, if the FilePieceBuffer, from EthStuff.mpas, variable is updated).

Thank you :)

VCC
Posts: 463
Joined: 08 Jun 2009 18:31
Location: Romania

Re: Connection drops when sending data over TCP

#2 Post by VCC » 28 Aug 2020 08:02

bump after 2 months
@mikroe can you look at this, please?

Thank you :)

User avatar
stefan.filipovic
mikroElektronika team
Posts: 1135
Joined: 18 Dec 2018 10:30

Re: Connection drops when sending data over TCP

#3 Post by stefan.filipovic » 04 Sep 2020 08:44

Hi,

I apologize for the late reply.

I'll try to reproduce this issue and will let you know what I've found out.

Kind regards,
Stefan Filipović

VCC
Posts: 463
Joined: 08 Jun 2009 18:31
Location: Romania

Re: Connection drops when sending data over TCP

#4 Post by VCC » 06 Sep 2020 06:52

stefan.filipovic wrote:
04 Sep 2020 08:44
I'll try to reproduce this issue and will let you know what I've found out.
Thank you :D

User avatar
stefan.filipovic
mikroElektronika team
Posts: 1135
Joined: 18 Dec 2018 10:30

Re: Connection drops when sending data over TCP

#5 Post by stefan.filipovic » 11 Sep 2020 11:41

Hi,

I've contacted you to the email associated with your forum account.

Please check your mailbox.

Kind regards,
Stefan Filipović

Post Reply

Return to “mikroPascal PRO for PIC32 General”