JKorf / Bitfinex.Net

A C# .netstandard client library for the Bitfinex REST and Websocket API focusing on clear usage and models
https://jkorf.github.io/Bitfinex.Net/
MIT License
88 stars 49 forks source link

The uncaught exception in the reconnection thread #59

Closed NektoDron closed 6 years ago

NektoDron commented 6 years ago

19:56:52.48[54]FATAL:UnhandledException: System.AggregateException: Произошла одна или несколько ошибок. ---> System.Exception: The socket is connecting, cannot connect again! в SuperSocket.ClientEngine.TcpClientSession.Connect(EndPoint remoteEndPoint) в CryptoExchange.Net.Implementation.BaseSocket.b35_0() в System.Threading.Tasks.Task1.InnerInvoke() в System.Threading.Tasks.Task.Execute() — Конец трассировка стека из предыдущего расположения, где возникло исключение — в System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) в System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) в System.Runtime.CompilerServices.ConfiguredTaskAwaitable1.ConfiguredTaskAwaiter.GetResult() в CryptoExchange.Net.Implementation.BaseSocket.d35.MoveNext() — Конец трассировка стека из предыдущего расположения, где возникло исключение — в System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) в System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) в System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1.ConfiguredTaskAwaiter.GetResult() в Bitfinex.Net.BitfinexSocketClient.d107.MoveNext() — Конец трассировки внутреннего стека исключений — в System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions) в System.Threading.Tasks.Task1.GetResultCore(Boolean waitCompletionNotification) в Bitfinex.Net.BitfinexSocketClient.StartInternal() в Bitfinex.Net.BitfinexSocketClient.Reconnect() в System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx) в System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx) в System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state) в System.Threading.ThreadHelper.ThreadStart() ---> (Внутреннее исключение #0) System.Exception: The socket is connecting, cannot connect again! в SuperSocket.ClientEngine.TcpClientSession.Connect(EndPoint remoteEndPoint) в CryptoExchange.Net.Implementation.BaseSocket.<Connect>b__35_0() в System.Threading.Tasks.Task1.InnerInvoke() в System.Threading.Tasks.Task.Execute() — Конец трассировка стека из предыдущего расположения, где возникло исключение — в System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) в System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) в System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1.ConfiguredTaskAwaiter.GetResult() в CryptoExchange.Net.Implementation.BaseSocket.d35.MoveNext() — Конец трассировка стека из предыдущего расположения, где возникло исключение — в System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) в System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) в System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1.ConfiguredTaskAwaiter.GetResult() в Bitfinex.Net.BitfinexSocketClient.d__107.MoveNext()<---

JKorf commented 6 years ago

Hi, do you have some more logging of what was going on before this exception happened?

NektoDron commented 6 years ago

Only this...

19:56:31.44[780]DEBUG:[битфайн] API: 2018/08/28 19:56:31:442 | Warning | No data received for 15 seconds, restarting connection 19:56:33.47[43]DEBUG:[битфайн] API: 2018/08/28 19:56:33:477 | Info | Resetting subscription requests 19:56:35.47[54]DEBUG:[битфайн] API: 2018/08/28 19:56:35:478 | Info | Going to try to reconnect 19:56:50.47[42]DEBUG:[битфайн] API: 2018/08/28 19:56:50:477 | Warning | Couldn't connect to socket 19:56:52.47[54]DEBUG:[битфайн] API: 2018/08/28 19:56:52:477 | Info | Going to try to reconnect 19:56:52.48[54]FATAL:UnhandledException: System.AggregateException: Произошла одна или несколько ошибок. ---> System.Exception: The socket is connecting, cannot connect again! в SuperSocket.ClientEngine.TcpClientSession.Connect(EndPoint remoteEndPoint)

also have today fatal log: 23:33:51.29[776]DEBUG:[битфайн] API: 2018/08/29 23:33:51:293 | Info | Received status code 20051, going to reconnect the websocket 23:33:51.45[6]DEBUG:[битфайн] API: 2018/08/29 23:33:51:451 | Info | Resetting subscription requests 23:33:53.45[811]DEBUG:[битфайн] API: 2018/08/29 23:33:53:450 | Info | Going to try to reconnect 23:33:53.78[43]DEBUG:[битфайн] API: 2018/08/29 23:33:53:781 | Info | Socket connection established 23:33:53.78[811]DEBUG:[битфайн] API: 2018/08/29 23:33:53:781 | Info | 3 subscriptions to resend 23:33:53.79[812]DEBUG:[битфайн] API: 2018/08/29 23:33:53:790 | Info | Websocket version: 2, platform status: operational 23:33:53.85[812]DEBUG:[битфайн] API: 2018/08/29 23:33:53:855 | Info | Authentication successful 23:33:53.85[45]DEBUG:[битфайн] API: 2018/08/29 23:33:53:855 | Info | Successfuly (re)subscribed Bitfinex.Net.Objects.SocketObjects.TickerSubscriptionRequest 23:33:53.93[31]DEBUG:[битфайн] API: 2018/08/29 23:33:53:934 | Info | Successfuly (re)subscribed Bitfinex.Net.Objects.SocketObjects.TradesSubscriptionRequest 23:33:54.04[45]DEBUG:[битфайн] API: 2018/08/29 23:33:54:043 | Info | Resetting subscription requests 23:33:56.04[28]DEBUG:[битфайн] API: 2018/08/29 23:33:56:043 | Info | Going to try to reconnect 23:33:56.39[771]DEBUG:[битфайн] API: 2018/08/29 23:33:56:391 | Info | Websocket version: 2, platform status: operational 23:33:56.39[43]DEBUG:[битфайн] API: 2018/08/29 23:33:56:392 | Info | Socket connection established 23:33:56.39[28]DEBUG:[битфайн] API: 2018/08/29 23:33:56:392 | Info | 3 subscriptions to resend 23:33:56.46[45]DEBUG:[битфайн] API: 2018/08/29 23:33:56:465 | Info | Successfuly (re)subscribed Bitfinex.Net.Objects.SocketObjects.TickerSubscriptionRequest 23:33:56.46[771]DEBUG:[битфайн] API: 2018/08/29 23:33:56:467 | Info | Authentication successful 23:33:56.55[45]DEBUG:[битфайн] API: 2018/08/29 23:33:56:544 | Info | Successfuly (re)subscribed Bitfinex.Net.Objects.SocketObjects.TradesSubscriptionRequest 23:33:56.94[45]DEBUG:[битфайн] API: 2018/08/29 23:33:56:946 | Info | Successfuly (re)subscribed Bitfinex.Net.Objects.SocketObjects.BookSubscriptionRequest 23:33:56.94[45]DEBUG:[битфайн] API: 2018/08/29 23:33:56:946 | Info | Successfully resubscribed 3 subscriptions 23:34:08.93[31]DEBUG:[битфайн] API: 2018/08/29 23:34:08:933 | Info | Successfuly (re)subscribed Bitfinex.Net.Objects.SocketObjects.BookSubscriptionRequest 23:34:08.93[31]DEBUG:[битфайн] API: 2018/08/29 23:34:08:933 | Info | Successfully resubscribed 3 subscriptions 23:34:09.10[771]DEBUG:[битфайн] API: 2018/08/29 23:34:09:101 | Error | Error in processing loop. System.InvalidOperationException, Последовательность содержит более одного соответствующего элемента, в System.Linq.Enumerable.SingleOrDefault[TSource](IEnumerable1 source, Func2 predicate) в Bitfinex.Net.BitfinexSocketClient.ProcessData(), message: [214,[7013,0,1]] ..... 03:05:18.05[771]DEBUG:[битфайн] API: 2018/08/30 03:05:18:057 | Error | Error in processing loop. System.InvalidOperationException, Последовательность содержит более одного соответствующего элемента, в System.Linq.Enumerable.SingleOrDefault[TSource](IEnumerable1 source, Func2 predicate) в Bitfinex.Net.BitfinexSocketClient.ProcessData(), message: [214,[7034.6,1,3.1]] 03:05:18.05[771]DEBUG:[битфайн] API: 2018/08/30 03:05:18:058 | Error | Error in processing loop. System.InvalidOperationException, Последовательность содержит более одного соответствующего элемента, в System.Linq.Enumerable.SingleOrDefault[TSource](IEnumerable1 source, Func2 predicate) в Bitfinex.Net.BitfinexSocketClient.ProcessData(), message: [214,[7034.4,1,0.01307664]] 03:05:18.05[771]DEBUG:[битфайн] API: 2018/08/30 03:05:18:058 | Error | Error in processing loop. System.InvalidOperationException, Последовательность содержит более одного соответствующего элемента, в System.Linq.Enumerable.SingleOrDefault[TSource](IEnumerable1 source, Func2 predicate) в Bitfinex.Net.BitfinexSocketClient.ProcessData(), message: [214,[7041.5,2,-0.603]] 03:05:18.05[771]DEBUG:[битфайн] API: 2018/08/30 03:05:18:058 | Error | Error in processing loop. System.InvalidOperationException, Последовательность содержит более одного соответствующего элемента, в System.Linq.Enumerable.SingleOrDefault[TSource](IEnumerable1 source, Func2 predicate) в Bitfinex.Net.BitfinexSocketClient.ProcessData(), message: [214,[7042.3,1,-10]] 03:05:18.44[771]DEBUG:[битфайн] API: 2018/08/30 03:05:18:444 | Error | Error in processing loop. System.InvalidOperationException, Последовательность содержит более одного соответствующего элемента, в System.Linq.Enumerable.SingleOrDefault[TSource](IEnumerable1 source, Func2 predicate) в Bitfinex.Net.BitfinexSocketClient.ProcessData(), message: [214,[7034.4,0,1]] 03:05:18.44[771]DEBUG:[битфайн] API: 2018/08/30 03:05:18:444 | Error | Error in processing loop. System.InvalidOperationException, Последовательность содержит более одного соответствующего элемента, в System.Linq.Enumerable.SingleOrDefault[TSource](IEnumerable1 source, Func2 predicate) в Bitfinex.Net.BitfinexSocketClient.ProcessData(), message: [214,[7030.1,0,1]] 03:05:18.44[771]DEBUG:[битфайн] API: 2018/08/30 03:05:18:444 | Error | Error in processing loop. System.InvalidOperationException, Последовательность содержит более одного соответствующего элемента, в System.Linq.Enumerable.SingleOrDefault[TSource](IEnumerable1 source, Func2 predicate) в Bitfinex.Net.BitfinexSocketClient.ProcessData(), message: [214,[7044,0,-1]] 03:05:18.44[771]DEBUG:[битфайн] API: 2018/08/30 03:05:18:445 | Error | Error in processing loop. System.InvalidOperationException, Последовательность содержит более одного соответствующего элемента, в System.Linq.Enumerable.SingleOrDefault[TSource](IEnumerable1 source, Func2 predicate) в Bitfinex.Net.BitfinexSocketClient.ProcessData(), message: [214,[7036.2,1,0.01171858]] 03:05:18.44[771]DEBUG:[битфайн] API: 2018/08/30 03:05:18:445 | Error | Error in processing loop. System.InvalidOperationException, Последовательность содержит более одного соответствующего элемента, в System.Linq.Enumerable.SingleOrDefault[TSource](IEnumerable1 source, Func2 predicate) в Bitfinex.Net.BitfinexSocketClient.ProcessData(), message: [214,[7029.3,1,3]] 03:05:18.44[771]DEBUG:[битфайн] API: 2018/08/30 03:05:18:445 | Error | Error in processing loop. System.InvalidOperationException, Последовательность содержит более одного соответствующего элемента, в System.Linq.Enumerable.SingleOrDefault[TSource](IEnumerable1 source, Func2 predicate) в Bitfinex.Net.BitfinexSocketClient.ProcessData(), message: [214,[7043.7,2,-2.19100001]] 03:05:18.94[43]DEBUG:[битфайн] API: 2018/08/30 03:05:18:948 | Info | Resetting subscription requests 03:05:20.95[734]DEBUG:[битфайн] API: 2018/08/30 03:05:20:950 | Info | Going to try to reconnect 03:05:21.31[842]DEBUG:[битфайн] API: 2018/08/30 03:05:21:315 | Info | Websocket version: 2, platform status: operational 03:05:21.31[44]DEBUG:[битфайн] API: 2018/08/30 03:05:21:315 | Info | Socket connection established 03:05:21.31[734]DEBUG:[битфайн] API: 2018/08/30 03:05:21:315 | Info | 3 subscriptions to resend 03:05:21.38[842]DEBUG:[битфайн] API: 2018/08/30 03:05:21:386 | Info | Authentication successful 03:05:21.38[31]DEBUG:[битфайн] API: 2018/08/30 03:05:21:387 | Info | Successfuly (re)subscribed Bitfinex.Net.Objects.SocketObjects.TickerSubscriptionRequest 03:05:21.45[44]DEBUG:[битфайн] API: 2018/08/30 03:05:21:459 | Info | Successfuly (re)subscribed Bitfinex.Net.Objects.SocketObjects.TradesSubscriptionRequest 03:05:22.34[43]DEBUG:[битфайн] API: 2018/08/30 03:05:22:340 | Info | Successfuly (re)subscribed Bitfinex.Net.Objects.SocketObjects.BookSubscriptionRequest 03:05:22.34[43]DEBUG:[битфайн] API: 2018/08/30 03:05:22:341 | Info | Successfully resubscribed 3 subscriptions

06:30:00.37[779]DEBUG:[битфайн] API: 2018/08/30 06:30:00:371 | Error | Socket error: IOException - Не удается прочитать данные из транспортного соединения: Попытка установить соединение была безуспешной, т.к. от другого компьютера за требуемое время не получен нужный отклик, или было разорвано уже установленное соединение из-за неверного отклика уже подключенного компьютера. 06:30:00.38[3]DEBUG:[битфайн] API: 2018/08/30 06:30:00:386 | Info | Resetting subscription requests 06:30:02.38[771]DEBUG:[битфайн] API: 2018/08/30 06:30:02:386 | Info | Going to try to reconnect 06:30:17.38[3]DEBUG:[битфайн] API: 2018/08/30 06:30:17:386 | Warning | Couldn't connect to socket 06:30:19.38[771]DEBUG:[битфайн] API: 2018/08/30 06:30:19:386 | Info | Going to try to reconnect 06:30:19.39[771]FATAL:UnhandledException: System.AggregateException: Произошла одна или несколько ошибок. ---> System.Exception: The socket is connecting, cannot connect again! в SuperSocket.ClientEngine.TcpClientSession.Connect(EndPoint remoteEndPoint) в CryptoExchange.Net.Implementation.BaseSocket.b__35_0() в System.Threading.Tasks.Task1.InnerInvoke() в System.Threading.Tasks.Task.Execute() --- Конец трассировка стека из предыдущего расположения, где возникло исключение --- в System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) в System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) в System.Runtime.CompilerServices.ConfiguredTaskAwaitable1.ConfiguredTaskAwaiter.GetResult() в CryptoExchange.Net.Implementation.BaseSocket.d35.MoveNext() --- Конец трассировка стека из предыдущего расположения, где возникло исключение --- в System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) в System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) в System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1.ConfiguredTaskAwaiter.GetResult() в Bitfinex.Net.BitfinexSocketClient.d107.MoveNext()

Errors "Error in processing loop" were from 23:34 to 03:05

NektoDron commented 6 years ago

It can't be fixed? Can you catch this exception to avoid the program crash?

NektoDron commented 6 years ago

I see the problem is that Reconnect method doesn't catch the exceptions though it's executed at the separated thread.

JKorf commented 6 years ago

Hi, can you try with the new version 1.2.2 which should be available in a few minutes? I fixed some bugs there.

NektoDron commented 6 years ago

It works fine already for a couple of days.

NektoDron commented 6 years ago

it on the new version: 10:22:44.17[363]DEBUG:[битфайн] API: 2018/09/19 10:22:44:173 | Warning | No data received for 20 seconds, restarting connection 10:22:46.24[329]DEBUG:[битфайн] API: 2018/09/19 10:22:46:249 | Info | Resetting subscription requests 10:22:48.25[338]DEBUG:[битфайн] API: 2018/09/19 10:22:48:252 | Info | Going to try to reconnect 10:23:03.25[298]DEBUG:[битфайн] API: 2018/09/19 10:23:03:252 | Warning | Couldn't connect to socket 10:23:05.25[338]DEBUG:[битфайн] API: 2018/09/19 10:23:05:252 | Info | Going to try to reconnect 10:23:05.26[338]FATAL:UnhandledException: System.AggregateException: Произошла одна или несколько ошибок. ---> System.Exception: The socket is connecting, cannot connect again! в SuperSocket.ClientEngine.TcpClientSession.Connect(EndPoint remoteEndPoint) в CryptoExchange.Net.Implementation.BaseSocket.b37_0() в System.Threading.Tasks.Task1.InnerInvoke() в System.Threading.Tasks.Task.Execute() — Конец трассировка стека из предыдущего расположения, где возникло исключение — в System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) в System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) в System.Runtime.CompilerServices.ConfiguredTaskAwaitable1.ConfiguredTaskAwaiter.GetResult() в CryptoExchange.Net.Implementation.BaseSocket.d37.MoveNext() — Конец трассировка стека из предыдущего расположения, где возникло исключение — в System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) в System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) в System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1.ConfiguredTaskAwaiter.GetResult() в Bitfinex.Net.BitfinexSocketClient.d107.MoveNext() — Конец трассировки внутреннего стека исключений — в System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions) в System.Threading.Tasks.Task1.GetResultCore(Boolean waitCompletionNotification) в Bitfinex.Net.BitfinexSocketClient.StartInternal() в Bitfinex.Net.BitfinexSocketClient.Reconnect() в System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx) в System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx) в System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state) в System.Threading.ThreadHelper.ThreadStart() ---> (Внутреннее исключение #0) System.Exception: The socket is connecting, cannot connect again! в SuperSocket.ClientEngine.TcpClientSession.Connect(EndPoint remoteEndPoint) в CryptoExchange.Net.Implementation.BaseSocket.<Connect>b__37_0() в System.Threading.Tasks.Task1.InnerInvoke() в System.Threading.Tasks.Task.Execute() — Конец трассировка стека из предыдущего расположения, где возникло исключение — в System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) в System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) в System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1.ConfiguredTaskAwaiter.GetResult() в CryptoExchange.Net.Implementation.BaseSocket.d37.MoveNext() — Конец трассировка стека из предыдущего расположения, где возникло исключение — в System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) в System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) в System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1.ConfiguredTaskAwaiter.GetResult() в Bitfinex.Net.BitfinexSocketClient.d__107.MoveNext()<---

JKorf commented 6 years ago

Hi, I've pushed a new version 1.2.3 that should fix this. Sometimes the socket of the underlying websocket library I use keeps hanging in the connecting state which causes this problem. New version creates a new socket when trying to reconnect so that should fix it.

NektoDron commented 6 years ago

on the versions Bitfinex 1.2.3 and Binance 3.26: 11:24:44.02[2]FATAL:UnobservedTaskException: AggregateException: AggregateException: Exception:The socket is connected, you needn't connect again!: at SuperSocket.ClientEngine.TcpClientSession.Connect(EndPoint remoteEndPoint) at CryptoExchange.Net.Implementation.BaseSocket.b__37_0() at System.Threading.Tasks.Task1.InnerInvoke() at System.Threading.Tasks.Task.Execute() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Runtime.CompilerServices.ConfiguredTaskAwaitable1.ConfiguredTaskAwaiter.GetResult() at CryptoExchange.Net.Implementation.BaseSocket.d__37.MoveNext()

JKorf commented 6 years ago

That's weird actually, as it makes a new socket when reconnecting. Could you maybe turn on Debug (LogVerbosity.Debug) logging and share the logging of when/before this happens? Appreciate your help trying to figure this out..

jojotutorial commented 6 years ago

I think I have experienced a similar issue here. nothing happened before but the socket suddenly shut down and keep reconnecting itself but failed.

Actually, I am running two programs at the same time using the same key pair, the program starts normally at the initial state but one of them would be crashed with the following error a few hours later. Does error have somthing do with this?

Thanks in advance!

2018/10/09 18:08:10:122 | Debug | Socket closed 2018/10/09 18:08:10:123 | Debug | Websocket closed 2018/10/09 18:08:10:123 | Debug | Disposing websocket 2018/10/09 18:08:10:200 | Debug | Socket state change Disconnecting => Disconnected INFO Connection lost. 2018/10/09 18:08:12:202 | Info | Going to try to reconnect 2018/10/09 18:08:12:202 | Debug | Socket state change Disconnected => Connecting 2018/10/09 18:08:12:202 | Debug | Created new socket 2018/10/09 18:08:12:202 | Debug | Connecting websocket 2018/10/09 18:08:13:114 | Debug | Socket opened 2018/10/09 18:08:13:114 | Debug | Socket state change Connecting => Connected 2018/10/09 18:08:13:114 | Debug | Websocket connected 2018/10/09 18:08:13:114 | Debug | Received message: {"event":"info","version":2,"serverId":"e1ef59ee-31c0-42a1-8e45-d456f10f3a3b","platform":{"status":1}} 2018/10/09 18:08:13:115 | Debug | Starting process loop 2018/10/09 18:08:13:115 | Debug | Processing {"event":"info","version":2,"serverId":"e1ef59ee-31c0-42a1-8e45-d456f10f3a3b","platform":{"status":1}} 2018/10/09 18:08:13:115 | Info | Websocket version: 2, platform status: operational 2018/10/09 18:08:13:115 | Info | Socket connection established 2018/10/09 18:08:13:116 | Info | 0 subscriptions to resend INFO Connection restored. 2018/10/09 18:08:27:738 | Debug | Closing websocket 2018/10/09 18:08:27:949 | Debug | Socket closed 2018/10/09 18:08:27:949 | Debug | Websocket closed 2018/10/09 18:08:27:949 | Debug | Disposing websocket 2018/10/09 18:08:27:961 | Debug | Socket state change Disconnecting => Disconnected INFO Connection lost. 2018/10/09 18:08:29:962 | Info | Going to try to reconnect 2018/10/09 18:08:29:962 | Debug | Socket state change Disconnected => Connecting 2018/10/09 18:08:29:962 | Debug | Created new socket 2018/10/09 18:08:29:962 | Debug | Connecting websocket 2018/10/09 18:08:30:924 | Debug | Socket opened 2018/10/09 18:08:30:925 | Debug | Socket state change Connecting => Connected 2018/10/09 18:08:30:925 | Debug | Received message: {"event":"info","version":2,"serverId":"d5dfdaab-10a3-43e3-bc43-470d1f9d51da","platform":{"status":1}} 2018/10/09 18:08:30:927 | Debug | Websocket connected 2018/10/09 18:08:30:929 | Debug | Starting process loop 2018/10/09 18:08:30:930 | Debug | Processing {"event":"info","version":2,"serverId":"d5dfdaab-10a3-43e3-bc43-470d1f9d51da","platform":{"status":1}} 2018/10/09 18:08:30:931 | Info | Websocket version: 2, platform status: operational 2018/10/09 18:08:30:936 | Info | Socket connection established INFO Connection restored.

capture

jojotutorial commented 6 years ago

On top of my last observation, it keeps saying that there is a "process loop ended" and "Authentication failed: nonce: small" issue.

May I ask what is the process loop about?

williamserror2

JKorf commented 6 years ago

The process loop is the thread that process all incoming messages. If you get the message that it's ended it means the thread is ending. It's normal when restarting the connecting. In the previous post you said you have 2 programs running which connect to the bitfinex server, this would explain your issues with nonce: small. The reconnecting issue is interesting..

It says 0 subscriptions to resend, did you actualy have subscriptions running when the reconnections started, do you also have logging of when this started? And I assume you're on the latest version? (1.2.4 atm)

jojotutorial commented 6 years ago

Thank you @JKorf .

And I assume you're on the latest version? (1.2.4 atm)

yes I am using the latest version

In the previous post you said you have 2 programs running which connect to the bitfinex server, this would explain your issues with nonce: small.

Yes, you are right. This happened when the same pair of listen key is used in the parallel programs. I resolve this issue by using different pairs of listen key in the parallel programs and now they work fine. :)

The reconnecting issue is interesting..It says 0 subscriptions to resend, did you actualy have subscriptions running when the reconnections started

yes I subscribe to the wallet, order and trades update once the connection is made....But once the connection is restored (refering to the previous post, I could detect the restore Action that you designed, and I print the line "INFO Connection Restored" myself), the socket closed very soon after around 20 sec. I workaround a bit by detecting the change of socket state: when "Disconnected" was detected, I restart the whole socket on my side.

your wrapper is great though! :+1: Can't wait to see more works on other exchanges (e.g. Huobi) from you ! ^^

JKorf commented 6 years ago

Thanks for the kind words ^^ I'm a bit busy atm, but the next exchange up would be Huobi.

Back to the problem, at some point the socket disconnected and didnt resubscribe the existing sub after reconnecting. Do you by any chance have logging of that point?

Btw, version 1.2.5 is available, it fixes an issue with sometimes missing the first message after subscribing.

frontierer commented 6 years ago

I am much appreciated for your effort, and I have recommended these to my friends!!! I also see a few potential exchanges such as Huobi and Gemini, do you have plans to develop them as well?

JKorf commented 6 years ago

Thanks :) I'll probably do Huobi as well as multiple people have requested that but I don't want to make any promises if or when that would be ready.

On topic: If this problem still exists please open a new issue and provide new logging.