[QFJ-651] To stop unsuccessful connection attempts after few retries Created: 14/Nov/11  Updated: 29/Nov/11  Resolved: 29/Nov/11

Status: Closed
Project: QuickFIX/J
Component/s: Networking
Affects Version/s: 1.5.1
Fix Version/s: None

Type: Other Priority: Default
Reporter: Mansoor Haider Assignee: Unassigned
Resolution: Won't Fix Votes: 0
Labels: QuickfixJ
Environment:

Java,windows 7



 Description   

How to stop unsuccessful connection attempts after few retries???



 Comments   
Comment by Grant Birchmeier [ 14/Nov/11 ]

This is not a good idea. Traditionally, you want your initiator to keep trying to connect. If the counterparty goes down for some unexpected reason, you want your initiator to keep re-attempting so that it will reconnect as soon as the counterparty comes back up.

If you wish to do this anyway, you can implement logic in your toAdmin or fromAdmin callbacks to shut your program down after however-many retries. I suggest that a better idea is to have it send a notification to a human (via email or whatnot) so that a human can decide whether to shut down the app and whether some fixes are needed.

Comment by Mansoor Haider [ 14/Nov/11 ]

Thanks for your suggestion,but do we have any quickfixj api support to do the same.

Comment by Mansoor Haider [ 15/Nov/11 ]

Hi,

Could please tell me as it is urgent for me..

Comment by Laurent Danesi [ 15/Nov/11 ]

Hi Mansoor,

If you want to prevent a Session to try to connect, you can call session.setEnabled(false). This will disconnect the Session if connected and avoid IoSessionInitiator to try to reconnect to the server.
As Grant said, you can count the attempts by adding a counter in toApp method of your Application implementation.

Regards,

Laurent DANESI

Comment by Mansoor Haider [ 15/Nov/11 ]

Hi,

Thanks for your suggestion,I will implement as you suggested and see whether it fulfils my requirement or not.

But I think quickfixj should implement a parameter in config file where we can state number of retries i.e. 0 could be value for retries till connected and any number should tell the number of retries.

Thanks,
Mansoor

Comment by Mansoor Haider [ 15/Nov/11 ]

Hi,

I tried but I unable to count the number of reconnection because my scenario is slightly different.
In my scenario the connection is refused and java.net.ConnectionException is thrown in the event log i.e. any of the method of application will not be called accept onCreate.Any other way or api support for such kind of scenario.

Thanks,
Mansoor

Comment by Christoph John [ 16/Nov/11 ]

Maybe you could use another approach and simply define a time after which the connection should be established and if not generate an alert. E.g. create a ScheduledExecutor which gets invoked say 5 minutes after onCreate() and which checks if the session is logged on and reacts accordingly.

Comment by Mansoor Haider [ 16/Nov/11 ]

Hi,

This seems to be a good and feasible for my scenario.I would implement you and reach back soon.However we can have similar functionality (suggested by me in my third comment) in coming versions of quickfixj because I have seen that quickfixj keeps a track of number of failed attempts in nested member private class of IoSessionInitiator.

Thanks
Mansoor

Comment by Mansoor Haider [ 16/Nov/11 ]

Hi,

I tried the new approach, I was able to count the number of retries but when I tried implementing session.setEnabled(false) I found that it is a private function of Session class.Any other suggestion to stop the connection attempts.

Thanks,
Mansoor

Comment by Laurent Danesi [ 16/Nov/11 ]

You can use logout method on Session

Comment by Mansoor Haider [ 16/Nov/11 ]

Hi,

I already have disconnect button implementing logout method but even clicking the disconnect button quickfixj does not stop reconnection attempts in this scenario.Here in my scenario it has not yet created connection over tcp/ip network i.e. due internet connection problem on side of acceptor or firewall and quickfixj still keeps on retring connection (remember it has not logged in yet).I could not stop the application because in the meanwhile it has already connected with one or more different acceptors so I have to stop the reconnection attempts for the one which is still retring because it is creating issues with other acceptors..

Thanks
Mansoor

Comment by Mansoor Haider [ 16/Nov/11 ]

Hi,

Is there any configuration through which I can set timeout??

Thanks
Mansoor

Comment by Mansoor Haider [ 18/Nov/11 ]

Hi,

I am still waiting for some solution.Please help.

Thanks
Mansoor

Comment by Christoph John [ 18/Nov/11 ]

Hi,

I have tested the suggested approach with Session.logout() and it works for me:

waiting for stop... time is 18 Nov 2011 08:41:33 GMT
<20111118-08:41:33, FIX.4.4:FixGateway->FixClient:dummy, error> (java.net.ConnectException: java.net.ConnectException: Connection refused (Next retry in 30000 milliseconds))
<20111118-08:42:03, FIX.4.4:FixGateway->FixClient:dummy, error> (java.net.ConnectException: java.net.ConnectException: Connection refused (Next retry in 30000 milliseconds))
calling Session.logout()... time is 18 Nov 2011 08:42:08 GMT
shutting down... time is 18 Nov 2011 08:43:08 GMT

You can see that he tries to connect every 30 seconds. After the second attempt I am calling logout() which prevents the connection attempts. You can see that there is no further attempt for a minute.

Comment by Mansoor Haider [ 18/Nov/11 ]

Hi,

I will try again the same thing because your error in the log same as mine so might help...

Thanks,
Mansoor

Comment by Christoph John [ 29/Nov/11 ]

Hi, can this ticket be closed now? As Grant pointed out, the normal behaviour would be to keep reconnecting. Did the suggested custom approach work for you?

Thanks,
Chris.

Comment by Mansoor Haider [ 29/Nov/11 ]

ya sure

Generated at Sat Nov 23 07:27:57 UTC 2024 using JIRA 7.5.2#75007-sha1:9f5725bb824792b3230a5d8716f0c13e296a3cae.