Re: [twsocket] Using the SslFTPClient
> I have 2 ftp components and both are logged into the server. The > first just does a LIST command every 3 seconds. The second does > the GET commands. > After 198 GETs I receive and error 10054. I re-connect both ftp > clients and after a further 198 GETs the same thing happens again. So you have continuous open control channels, and do 198 SSL gets, each will open and close a new data channel, with a new SSL negotiation and session each time. There are no known restrictions in ICS over number of SSL sessions that can be opened, I've done thousands in a single thread. However ICS does have various SSL session caching options, and depending on which you are using that might be the issue. Never really looked closely at session caching, it just seems to work. So most likely the FTP server SSL implementation is bad. Have you tried downloading 250 files using FileZilla and SSL? Should replicate what your application is doing. I would say long idle FTP sessions are not a good idea, servers like to timeout long sessions and are not usually tested for long idle periods. So having your application periodically log-off and on again may help long term, you'll need that anyway to cope with bad internet connections. 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
Re: [twsocket] Using the SslFTPClient
1: The PROT issue is indeed irrelevent, but a simple fix at least lets you know if PROT is supported. Something like this maybe, so long as ftpFeatProt is added to the set: if Pos('PROT', Feat) = 1 then begin if Feat = 'PROT' then FSupportedExtensions := FSupportedExtensions + [ftpFeatProt]; if Pos('C', Feat) > 5 then FSupportedExtensions := FSupportedExtensions + [ftpFeatProtC]; if (Pos('P', Feat) > 5) then FSupportedExtensions := FSupportedExtensions + [ftpFeatProtP]; 2: This server requires Passive mode when using AuthTls, so another step forward. 3: Now I have an interesting one and it's difficult to know from which end the problem is being initiated. I have 2 ftp components and both are logged into the server. The first just does a LIST command every 3 seconds. The second does the GET commands. After 198 GETs I receive and error 10054. I re-connect both ftp clients and after a further 198 GETs the same thing happens again. Error 10054 is a "connection reset by peer" message, which would imply that it's the server that has initiated this. But is there anything at the ftp client end that could cause the server to behave as it does? If I log into the server with the SSL Mode set to sslTypeNone, this problem does not occur. Any clues much appreciated. Graham On 26/12/2017 17:34, Angus Robertson - Magenta Systems Ltd wrote: Hold fire on what I said before. I am still in learning mode as this is all new to me. I would suggest you at least try the compiled version of my high level TMagFtp component from: https://www.magsys.co.uk/delphi/magxfer.asp which handles all this stuff automatically. If TMagFtp works, then you can look at the source to see why. The one thing I have found is that when I execute the featAsync, I do not see the PROT in the list of supported extensions. When I look at the source code, you are looking for "PROT C" or "PROT P". This server only returns "PROT". This may be irrelevant, the feature list is designed to tell you which commands you can use, they don't stop you using them anyway (probably, not looked at the code in a while). 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
Re: [twsocket] ICS OnDataAvailable
Hi Alessandro, No that is not a problem and the right way to synchronize data between threads. Met vriendelijke groeten, Wilfried Mestdagh Op 10-01-18 om 09:07 schreef Alessandro Miorelli: Hi Wilfried, Thank you, now I understand. One question again: I call PostThreadMessageA or PostMessage in the OnDataAvailable Is it a problem? Regards Ing. Alessandro Miorelli Software Engineer Microgate S.r.l. Via Stradivari 4 39100 Bolzano (BZ) Italy www.microgate.it Tel. +390471501532 -Original Message- From: TWSocket [mailto:twsocket-boun...@lists.elists.org] On Behalf Of Wilfried Mestdagh Sent: Wednesday, January 10, 2018 8:05 AM To: twsoc...@elists.org Subject: Re: [twsocket] ICS OnDataAvailable Hi Alessandro, Just receive with FWSocket.Receive(...) in your char array. If there is really no data then nothing will be copied into your buffer and the result will be <= 0. Then just exit the event (don't loop). When there is again data then OnDataAvailable will be called again. Rgds Met vriendelijke groeten, Wilfried Mestdagh Op 09-01-18 om 19:53 schreef Alessandro Miorelli: Thank you so much Wilfred for your quick answer. One question: I do that int length = FWSocket->RcvdCount; if(length == 0) return; char *str = new char[length + 1]; FWSocket->Receive(str, length); str[length] = 0; you wrote that sometimes FWSocket->RcvdCount is 0. What should I do to receive data? I prefer to read char array because I have chars with value < 0x20 Thank you Regards Ing. Alessandro Miorelli Software Engineer Microgate S.r.l. Via Stradivari 4 39100 Bolzano (BZ) Italy www.microgate.it Tel. +390471501532 -Original Message- From: TWSocket [mailto:twsocket-boun...@lists.elists.org] On Behalf Of Wilfried Mestdagh Sent: Tuesday, January 9, 2018 6:07 PM To: twsoc...@elists.org Subject: Re: [twsocket] ICS OnDataAvailable I see a second problem in your code: } while (length != totalDataReceived && FWSocket->State == wsConnected && !Terminated && timeout < MAX_TIMEOUT); Dont loop in DataAvailable. Just receive the part of data that is received and exit. When next chunck of data come in the OnDataAvailable will be fired again. TCP protocol does not respect data boundaries. Met vriendelijke groeten, Wilfried Mestdagh Op 09-01-18 om 18:01 schreef Wilfried Mestdagh: Hi, The problem could be in this peace of code: int length = FWSocket->RcvdCount; if(length == 0) { Debug::DebugString(AnsiString("FWSocketDataAvailable length ") + IntToStr(length)); return; } RcvdCount is not reliable. This is not a TWSocket problem but a Windows problem. Even if it returns zero the you should try to receive data. So just leave that part out of it. Rgds, Wilfried Met vriendelijke groeten, Wilfried Mestdagh Op 09-01-18 om 15:48 schreef Alessandro Miorelli: Hi, I'm working with ICS and BCB6 All works fine but sometimes I don't receive OnDataAvailable event anymore. In attach the code. Please could you help me Regards Ing. Alessandro Miorelli Software Engineer -- 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
Re: [twsocket] ICS OnDataAvailable
Hi Wilfried, Thank you, now I understand. One question again: I call PostThreadMessageA or PostMessage in the OnDataAvailable Is it a problem? Regards Ing. Alessandro Miorelli Software Engineer Microgate S.r.l. Via Stradivari 4 39100 Bolzano (BZ) Italy www.microgate.it Tel. +390471501532 -Original Message- From: TWSocket [mailto:twsocket-boun...@lists.elists.org] On Behalf Of Wilfried Mestdagh Sent: Wednesday, January 10, 2018 8:05 AM To: twsoc...@elists.org Subject: Re: [twsocket] ICS OnDataAvailable Hi Alessandro, Just receive with FWSocket.Receive(...) in your char array. If there is really no data then nothing will be copied into your buffer and the result will be <= 0. Then just exit the event (don't loop). When there is again data then OnDataAvailable will be called again. Rgds Met vriendelijke groeten, Wilfried Mestdagh Op 09-01-18 om 19:53 schreef Alessandro Miorelli: > Thank you so much Wilfred for your quick answer. > > One question: > > I do that > > int length = FWSocket->RcvdCount; > > if(length == 0) > return; > > char *str = new char[length + 1]; > > FWSocket->Receive(str, length); > > str[length] = 0; > > you wrote that sometimes FWSocket->RcvdCount is 0. > > What should I do to receive data? > > I prefer to read char array because I have chars with value < 0x20 > > Thank you > Regards > Ing. Alessandro Miorelli > > Software Engineer > Microgate S.r.l. > Via Stradivari 4 > 39100 Bolzano (BZ) Italy > www.microgate.it > Tel. +390471501532 > > -Original Message- > From: TWSocket [mailto:twsocket-boun...@lists.elists.org] On Behalf Of > Wilfried Mestdagh > Sent: Tuesday, January 9, 2018 6:07 PM > To: twsoc...@elists.org > Subject: Re: [twsocket] ICS OnDataAvailable > > I see a second problem in your code: > > } while (length != totalDataReceived && FWSocket->State == > wsConnected && !Terminated && timeout < MAX_TIMEOUT); > > Dont loop in DataAvailable. Just receive the part of data that is > received and exit. When next chunck of data come in the > OnDataAvailable will be fired again. TCP protocol does not respect data boundaries. > > Met vriendelijke groeten, > Wilfried Mestdagh > > Op 09-01-18 om 18:01 schreef Wilfried Mestdagh: >> Hi, >> >> The problem could be in this peace of code: >> >> int length = FWSocket->RcvdCount; >> >> if(length == 0) >> { >> Debug::DebugString(AnsiString("FWSocketDataAvailable length >> ") >> + IntToStr(length)); >> return; >> } >> >> RcvdCount is not reliable. This is not a TWSocket problem but a >> Windows problem. Even if it returns zero the you should try to >> receive data. So just leave that part out of it. >> >> Rgds, Wilfried >> >> Met vriendelijke groeten, >> Wilfried Mestdagh >> >> Op 09-01-18 om 15:48 schreef Alessandro Miorelli: >>> Hi, >>> >>> I'm working with ICS and BCB6 >>> >>> All works fine but sometimes I don't receive OnDataAvailable event >>> anymore. >>> >>> In attach the code. >>> >>> Please could you help me >>> >>> >>> Regards >>> >>> >>> Ing. Alessandro Miorelli >>> >>> >>> Software Engineer >>> >>> >>> >>> > -- > 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