I am using indy's tcp server / client and everything works fine(fixed a few bugs),but there is one bug that is bugging me.
When I freeze all the threads & then kill the process of the tcp client the server crashes and keeps raising that error^ nonstop in the tcpserver.
Is there a way to handle that error in Delphi 6 and other socket errors and prevent the server from crashing(I am using delphi 6 / windows 8 64-bits(probably not needed but I never tested it on my win 7 so...)/ indy 9 / Indy TCP Server & Client)?
Your server is not crashing. EIdSocketError is a perfectly normal exception for TIdTCPServer to encounter when a client connection is closed/lost. That is normal behavior. TIdTCPserver will handle it internally for you and close the socket if the exception escapes into the server (which you should allow it to do - if you catch it yourself, re-raise it after you are done with it). The only reason you see the exception at all is because the debugger reports it before your app sees it. Simply press F9 to let the debugger pass it to the app for normal handling, or else configure the debugger to ignore Indy EIdException-based exceptions.
And please make sure you use a more recent version of Indy than that installed in D7 (you need to remove the old version first). There are crashing threading bugs < 9.0.18
Related
I am encountering some problems using some code that worked for ages involving Indy and the download of a web page. I use RAD Studio 10.2 Tokyo.
The web page is as follows:
https://donet.rfi.it/RFIPlatform/showDoc.do?compartimentoHidden=AN&docTypeHidden=CC
The code I am using is part of an application which has the same code since 2011 and it always worked well. The code is as follows:
IDHTTP1.Get('https://donet.rfi.it/RFIPlatform/showDoc.do?compartimentoHidden=AN&docTypeHidden=CC');
I am getting a "Connection Reset by Peer 10054" error since the website went down, some days ago, and when it came up again, the code did not work anymore.
The aforementioned web page can be called from the browser, can even be downloaded with WGET, but Indy is failing.
I tried to play with various options (Cookie Handling, Handle Redirects, HTTPOptions, etc...) and I also updated the SSL libraries to 1.0.2q (Indy cannot use OpenSSL 1.1.0 yet), but the whole thing just doesn't want to work.
Can someone help me figure out what is going on? It has to be for sure something on the website, since the code I use is the same since 2011 and it has always worked. And before that, the same code worked in a similar application since 2008.
Indy's TIdSSLIOHandlerSocketOpenSSL component enables only TLS 1.0 by default. The website in question (https://donet.rfi.it) does not accept TLS 1.0 anymore (probably why it went offline, to update its software), it will accept only TLS 1.1+ now.
TIdHTTP is able to successfully establish a TCP/IP connection to donet.rfi.it:443, but as soon as TIdSSLIOHandlerSocketOpenSSL sends a TLS 1.0 handshake request, the server forcibly closes the TCP connection. You are getting the "connection reset by peer" error while TIdSSLIOHandlerSocketOpenSSL is trying to read the server's handshake response.
You need to configure TIdSSLIOHandlerSocketOpenSSL to enable TLS 1.1 and/or 1.2. You can do that via its SSLOptions.SSLVersions property. Then TIdHTTP.Get() will work again (I tested it).
My D7 dBExpress project is supposed to connect to a local Interbase XE7 server.
It has the usual DBX setup: SqlConnection, SqlQuery, DataSetProvider and
ClientDataSet and does a simple 'select * from mytable'.
Last time I used it, it was working fine, but today when I ran it inside the IDE,
I get an exception as I call
ClientDataSet1.Open;
in my FormCreate (that call is the entire code of the project, btw). The
exception is an EDatabaseError with msg "No mapping for Error Code Found." and happens in TSqlConnection.DoConnect
That sounds familiar - I got that error myself one time, when I went back to an IB project after a few weeks.
It turned out that in the meantime something had sneaked Firebird onto my machine and it had hijacked the port IB usually listens on, and it was actually this FB server which was rejecting the connection, not the Interbase one!
Take a look under Services to see whether there is an FB server running. If there are, close it down (and start the IB server if not already running, of course). Then try your DBX project again.
Somewhere in the IB docs, I found something which seemed to suggest there was a way of getting FB and IB servers to coexist, but to avoid falling into a similar trap another time, I wrote a couple of batch files to shut down one of them and start the other. One is called "UseIB" and contains:
net stop "Firebird server - DefaultInstance"
net start "InterBase XE7 Server gds_db"
The other one, "UseFB" just does the opposite, of course.
The Delphi app tethering manager reserves 20 ports in the range from 2020-2039 to start up its communication threads.
I wanted to find out what happens, when the 21st application is started on the same computer. It turns out that this application just hangs unresponsive until it is killed and I haven't found a way to terminate it gracefully.
To reproduce, just drop a TTetheringManager and a TTetheringProfile on an empty form, connect the profile to the Manager, compile, start the application 20 times outside the IDE and finally start the 21st instance in the IDE.
This is what I have found out so far:
In System.Tether.NetworkAdapter: procedure TTetheringNetworkManagerCommunicationThread.Execute;
an ETetheringException.Create(SManagerNetworkCreation) is raised when either the TCP or the UDP communication server could not be started. So far so good.
This exception shows up in the Debugger. When I continue and step through the following code, the application finally hangs in System: function AcquireExceptionObject and never returns.
Since the application is raised during Application.Run, I tried to catch the Exception via:
try
Application.Run;
except
ShowMessage('Something went terribly wrong!');
end;
but this didn't work. Any suggestions how I can catch (or prevent) this exception?
Since this really seems to be a bug, I filed a quality report for it: https://quality.embarcadero.com/browse/RSP-11345
as the subject says, just close a DS App with 1 open connection and it hangs.
The issue is related to procedure TIdScheduler.TerminateAllYarns;because it get into an infinite loop trying to close all yarns.
The issue is similar to this reported by another user.
http://www.codenewsfast.com/cnf/article/0/permalink.art-ng2026q2000
Regards,
Same problem for me too. I've implemented a DataSnap CallBack example in Delphi XE3 and Delphi 10 Seattle: both hangs if one or more client are connected to the server.
But they hangs only when I close directly the server Windows application.
Try calling before:
ServerContainer1.DSServer1.Stop;
It works for me.
Im using Delphi XE 5/6, default Indy version, Windows 7. IdMappedPortTCP (component put on Form) redirect local stream from FFmpeg to Twitch.tv and always near 2 hours of streaming i have IdMappedPortTCP1ExceptionSocket Error # 10053
Software caused connection abort. Tried TCPRelay and no problems so i guess something must be wrong in my app. Thanks for suggestions.
10053 is a network error. Most likely a firewall or router is cutting the connection after it is idle for too long. I would try using Indy's TIdEventStream class as explained in the answer to this post:
How to avoid getting an error 10053 (WSAECONNABORTED) if a HttpGet operation in Android is lasting too long?