Petersoj / alpaca-java

A Java API for Alpaca, the commission free, algo friendly, stock trading broker. https://alpaca.markets
https://petersoj.github.io/alpaca-java/
MIT License
197 stars 82 forks source link

When websocket closes abnormally, alpaca-Java doesn't resubscribe to the previous channels upon reconnect #67

Closed justinmvail closed 3 years ago

justinmvail commented 4 years ago

There is an issue with the polygon websocket closing unexpectedly with the message: "CLOSED_ABNORMALLY" This, by itself, is a polygon issue. I even get the same thing using wscat: Disconnected (code: 1006, reason: ""). This, unfortunately, is an error the consumer must handle.

Alpaca-java attempts to handle the issue by reconnecting which appears to succeed. However, it doesn't resubscribe to any of the channels from before the abnormal closure. This results in a connection that isn't listening to anything.

I believe that the reconnect logic needs to include resubscribe logic as well.

It appears that the GO alpaca library has gone through a similar issue: https://github.com/alpacahq/alpaca-trade-api-go/issues/48

jetonbacaj commented 3 years ago

There is a PR for this; https://github.com/Petersoj/alpaca-java/pull/70

Petersoj commented 3 years ago

70 has been merged and will be released on Monday or Tuesday sometime.