Hello Everyone,

I think i found a solution...

First, i will to to explain what i understand.

How works my applications :
It connects (TWSocket) to 3 remote devices which provide data (30 chars)
every 10 seconds each.
It binds a server (TWSocketServer), about 8 clients are connected on it.

This application compute the data from the remote device, and send the
results to the 8 clients.
All the flow is based on a TTimer (apart the OnDataAvaible of the server and
data retreived from the client, they push data in a FIFO).

The problem :
After many hours (26 hours), when the clients resynchronize all the data or
a new client connects to the server, the application resend all the dat to
them :
It is done in the TTimer event.

So here, the application freeze a little time to compute and send the data
(maybe 5-20 seconds) :
A) If I a call the SendStr to send my data, everything is break :
 - Data are not sent to the clients.
 - I cannot etablish a new connection to my TWServerSocket (the connection
is refused).
 - But the remote device are not disconnected.
  - each TWSocket says "i'm always connected".
  - remote device tell the same thing.
  - Netstat confirm.

B) If i comment the SendStr, so i only compute my data, the application
freeze less time (below 10 seconds).
 - Connection to the remote device still retrieving data.
 - I can always etablish new connection to my TWSocketServer.
 - ClientCount return by TWServerSocket is fine.


The solution (or workaround !) :
I simply replace TWSocketThrdServer and TWSocketThrdClient instead of
TWSocketServer and TWSocketClient, and it seems to not break anything now
(youhou) !!!

Why ? 
I think that freezing the main thread breaks a lot of thing...
But until here (and for about 10years), everything worked fine.
For me, the "only" thing we change is that we updated from BCB6 to XE3 and
to ICS v8.16 (i mean our source code stay the same).
I will make a lot, lot of test to see the difference with the threaded
server/client.
On some application i see that they use a TAntiFreeze component maybe it can
help too, but i did not try.


@Tim Hyde :
Thanks a lot to point me to your old thread, i was thinking that the
TWSocketServer and TWSocket already implementing thread fonctionnality.
And i think you have got the solution...

@Angus
I undestand that i'm not very clear in all the description, but i'm not
English native, and i really provide you all what i have !!!
I really know that it is frustrating when someone say my program do not work
(and a most part of the time this is not the case...), 
so i understand your reponse, so i really do not want to say "ICS do not
work", but i need help with your program, so please you better know the best
practice to implement it !

So thanks for the works !


Another last "problem" :
OverbyteIcsWSocketTS.pas is not included in the CBXe3Install nor in the
CBXe3VclFmxInstall.
The compiler ask for Form.dcu or Controls.dcu depending on what i'm
compiling (i'm a really newbie for that...)


Best regards,
Moro Alexandre.


-----Message d'origine-----
De : TWSocket [mailto:twsocket-boun...@lists.elists.org] De la part de
François Piette
Envoyé : samedi 3 décembre 2016 17:13
À : 'ICS support mailing'
Objet : Re: [twsocket] TWSocket Client Timeout.

Hello Alexandre,

There is nothing preventing data from a TTimer event.
Are you using "sync" functions or "async" functions ? Are you using wait
loops ?

When you send data from TTimer event, is this "transparent" to the protocol
you are using ? Maybe the data send from TTimer interfere with data sent (or
received) from other parts of your program?


--
francois.pie...@overbyte.be
The author of the freeware multi-tier middleware MidWare The author of the
freeware Internet Component Suite (ICS) http://www.overbyte.be




-----Message d'origine-----
De : TWSocket [mailto:twsocket-boun...@lists.elists.org] De la part de Moro
Alexandre Envoyé : vendredi 2 décembre 2016 13:44 À : 'ICS support mailing'
Objet : Re: [twsocket] TWSocket Client Timeout.

Hello !

I finaly found where comes from the problem :
When the clients connects to my server, i send to everyone a lot of data
from a TTimer.

If i remove the SendStr() call, everything works fine !!!

So please,
1) Can you explain me what is wrong in calling SendStr from a TTimer ?
2) How can this call, block every differents object based on TWSocket,
server object and client object ?
3) Why there are no error event nor exception throw...

Solution :
1)
I tried to set mpWSocketServer->MultiThread = true; But it doesn't change
anything...

2)
Do i have to implement a Thread for all the SendStr be apart from the main
thread ?
I create a Thread, pass the TWSocketServer object as parameters, and a FIFO
list with event.
When i complete this list, the thread process the new data and SendStr...


I'm shocked that this call can interfere seperate object...

Thank you !

Best regards,
Moro Alexandre.


-----Message d'origine-----
De : TWSocket [mailto:twsocket-boun...@lists.elists.org] De la part de Moro
Alexandre Envoyé : vendredi 2 décembre 2016 08:14 À : 'ICS support mailing'
Objet : Re: [twsocket] TWSocket Client Timeout.

I trying to investigate more and more and i see that i cannot open new
sockets on the server, it refuse the connection, below is the packets
captured in wireshark :
Document joint : spuriousretransmission.pcapng

The application i openned who crashed all the twsocket open two new socket
on this server !
And in netstat the server socket are still in listenning state, (it happen
on localhost and from a remote computer).

Moreover the last 4 connection are in FIN_WAIT_2

Maybe it is a start...

Moro Alexandre.

-----Message d'origine-----
De : TWSocket [mailto:twsocket-boun...@lists.elists.org] De la part de Angus
Robertson - Magenta Systems Ltd Envoyé : jeudi 1 décembre 2016 16:54 À :
twsocket@lists.elists.org Objet : Re: [twsocket] TWSocket Client Timeout.

> In this time, did you already ear something like that with ICS ?
> Have you any idea where data can be blocked, and in this state what 
> can i do more than inspecting by wireshark and netstat ???

If I understand you correctly, you want to keep remote TCP/IP sockets
connected for several days at a time, presumably over a LAN or maybe a WAN? 

There are so many ways a connection can be lost, routers and switches,
hardware issues, software interference, Windows Updates, etc.  

Even with keep alive, TCP/IP sockets can say connected but not be, the only
reliable way is to send and echo data, a proper handshake. 

The probability of it being a bug in ICS that no-one else has noticed is
highly unlikely, but not impossible, as explained previously I did fix a
timeout issue that caused a socket to be closed earlier this year, which I
found in one of my applications. 

You really need to find a way of bullet proofing your application, so it
reconnects if nothing is received for x second/minutes/hours, or use regular
handshaking for a more reliable and shorter timeout. 



Angus





--
To unsubscribe or change your settings for TWSocket mailing list please goto
http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be


--
To unsubscribe or change your settings for TWSocket mailing list please goto
http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be


--
To unsubscribe or change your settings for TWSocket mailing list please goto
http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be

--
To unsubscribe or change your settings for TWSocket mailing list please goto
http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be


-- 
To unsubscribe or change your settings for TWSocket mailing list
please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be

Reply via email to