Dukascopy Support Board http://www.dukascopy.com/swiss/english/forex/jforex/forum/ |
|
Errors in threads after IClient.disconnect http://www.dukascopy.com/swiss/english/forex/jforex/forum/viewtopic.php?f=16&t=51401 |
Page 1 of 1 |
Author: | fxbird [ Tue 17 Jun, 2014, 12:37 ] |
Post subject: | Errors in threads after IClient.disconnect |
I am trying to get account information (for now) on my internal webserver. I can get the information I need from the API. But unfortunately the dukascopy thread keeps running and generating errors. How can I kill the thread when stopping the strategy and disconnecting the client? I get the account information with the following basic strategy (as found in the forum). package forex.JfUtil;I keep the other methods empty. Then I launch the strategy from a servlet with the following code: import com.dukascopy.api.system.ClientFactory;I would expect that dukascopy threads would stop after the strategy ends and the client is disconnected. My app logs are: 18:58:22 [ http-bio-7070-exec-4] - INFO - forex.web.BalanceFromDuka: 39 - Connected to Dukascopy servers Unfortunately, I keep getting the following errors every minute in my logs: 18:59:19 [CriteriaIsolationExecutorThreadsMonitor] - ERROR - dukascopy.transport.client.CriteriaThread: 48 - Found not fired event, with wait time > 2 sec: {"userId":"...If I launch the strategy a second time to get additional information, it will create a second thread which will also remain active and will also generate errors. Therefore the number of threads keeps increasing on the webserver Even If I stop my webapp, these threads are still running. I realized there are more threads still running after disconnecting iClient (although it seems only CriteriaIsolationExecutorThreadsMonitor creates problems): SEVERE: The web application [/forex-beta] appears to have started a thread named [CriteriaIsolationExecutorThreadsMonitor] but has failed to stop it. This is very likely to create a memory leak. The CriteriaIsolationExecutorThreadsMonitor thread is problematic because it keeps generating errors in the log and the number of these threads increases each time I launch the strategy to get data. So am I doing something wrong when ending the strategy and disconnecting the client? Should I wait for other threads to end before? How can I get rid of the dukascopy.transport.client.CriteriaThread errors and stop the number of thread to increase? I am using DDS2-jClient-JForex:2.36 Thank you in advance for any help |
Author: | fxbird [ Wed 18 Jun, 2014, 17:52 ] |
Post subject: | Re: Errors in threads after IClient.stopStrategy and IClient.disconnect |
To avoid "asynchronous issues", I changed my code to : 1 - stop the strategy directly at the end of MyFirstStrategy.Onstart with myContext.stop() 2 - implement client.setSystemListener(new ISystemListener()... to disconnect the client only in the onStop method. Therefore I am sure that the strategy has actually been stopped before I disconnect. Unfortunately, the problem is still there - the Error "transport.client.CriteriaThread - Found not fired event, with wait time > 2 sec" still appears every minute for most CriteriaIsolationExecutorThreadsMonitor threads (but actually not for all of them). Right now, I have 5 CriteriaIsolationExecutorThreadsMonitor threads running and 3 of these threads are generating the error (every minute for each thread). - the number of CriteriaIsolationExecutorThreadsMonitor threads increases after each StartStrategy (ie each time I launch the servlet to get account information) Edit: actually it looks like the OnDisconnect() in client.setSystemListener(new ISystemListener()... is never executed. I can't find any logical explanation... |
Author: | hyperscalper [ Thu 19 Jun, 2014, 06:08 ] |
Post subject: | Re: Errors in threads after IClient.stopStrategy and IClient.disconnect |
First of all, I wouldn't attempt to design things this way, using a servlet and a transient login, but... At the end of your onStart you should probably call context.stop(); ...if you want to terminate the IStrategy instance but there's probably more to debugging a design like this, than that observation. .startStrategy isn't a synchronous blocking call so you'll need to do some thread waiting, and a whole lot more issues, I'd think..... HyperScalper |
Author: | fxbird [ Thu 19 Jun, 2014, 07:47 ] |
Post subject: | Re: Errors in threads after IClient.stopStrategy and IClient.disconnect |
Thank you for your answer. Because it's asynchronous, I already changed my code to used context.stop(); and client.setSystemListener(new ISystemListener() { (.... (as mentionned in post #2).
public class MyStrategy1 implements IStrategy{But the errors are still there (see post #2), and the OnDisconnect() is never executed. Besides these problems, the asynchronous process seems fine in my logs 18:54:14 [http-bio-7070-exec-2] - INFO - BalanceFromDuka: 71 - Connecting to Dukascopy servers ...Indeed, the alternative solution would be to use a permanent connection to the server. I thought this would not make sense to keep it open 24*7 to mostly get account and orders data from time to time (at least for now). |
Author: | API Support [ Thu 19 Jun, 2014, 13:53 ] |
Post subject: | Re: Errors in threads after IClient.disconnect |
Why would you need to disconnect on strategy stop if you want to keep working in the same account after the strategy stop? Simply remain connected as long as you are working the same account. |
Author: | fxbird [ Fri 20 Jun, 2014, 09:56 ] |
Post subject: | Re: Errors in threads after IClient.disconnect |
Ok, for now I remain connected permanently. However: - I need to disconnect and unload the thread before undeploying or stopping the webapp. To do that, I use disconnect() method. But it doesn't unload all threads. That means I must stop the web server each time I need to undeploy the webapp (basically each time I update my code with a new version) to avoid memory leaks and increase in # of threads. This is a personal internal server, but still, this is not the only webapp running on it, so this is annoying. - In the future, I will need to change account (from demo to live and vice et versa) without having to stop the webserver. So yes, right now I can live with this by remaining connected and stopping the webserver each time I have new code; but it would be really nice if in the future it would be possible to fix this issue Thank you |
Author: | API Support [ Fri 20 Jun, 2014, 15:32 ] |
Post subject: | Re: Errors in threads after IClient.disconnect |
fxbird wrote: However: We are going to have a look if there are any additional disposal procedures to be added on the client disconnect.
- I need to disconnect and unload the thread before undeploying or stopping the webapp. To do that, I use disconnect() method. But it doesn't unload all threads. That means I must stop the web server each time I need to undeploy the webapp (basically each time I update my code with a new version) to avoid memory leaks and increase in # of threads. This is a personal internal server, but still, this is not the only webapp running on it, so this is annoying. - In the future, I will need to change account (from demo to live and vice et versa) without having to stop the webserver. |
Author: | ftasso [ Mon 03 May, 2021, 19:55 ] |
Post subject: | Re: Errors in threads after IClient.disconnect |
Hello, I have the same problem using servlet. Have you news/suggestions about this issue? Any workaround should be a better solution then restarting the webserver. Thank you, Fabrizio |
Author: | fxbird [ Wed 05 May, 2021, 09:23 ] |
Post subject: | Re: Errors in threads after IClient.disconnect |
That was a long time ago; now I connect when starting the servlet server, and disconnect when stopping it. |
Author: | ftasso [ Thu 06 May, 2021, 11:20 ] |
Post subject: | Re: Errors in threads after IClient.disconnect |
Hello, me also make the connect call when servlet starts and disconnect when I stop the webapp (not the server). The problem still remains, I have the following threads not properly ended: - ActivityLogger - TimeChangeTrackerThread - some others processes regarding netty Do you have a fully shutdown of the client connection whitout memory leaks? Thank you, Fabrizio |
Author: | fxbird [ Tue 11 May, 2021, 17:28 ] |
Post subject: | Re: Errors in threads after IClient.disconnect |
Not that I can remember, but I would have to check. My server is not easily accessible anymore, so not so easy to check ftasso wrote: Hello,
me also make the connect call when servlet starts and disconnect when I stop the webapp (not the server). The problem still remains, I have the following threads not properly ended: - ActivityLogger - TimeChangeTrackerThread - some others processes regarding netty Do you have a fully shutdown of the client connection whitout memory leaks? Thank you, Fabrizio |
Page 1 of 1 |