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
198 stars 84 forks source link

Polygon Websocket Not Connecting on JDK 11, 12, or 13. #57

Closed dallinlarsen closed 4 years ago

dallinlarsen commented 4 years ago

When I try to connect to the Polygon web socket I get an error that reads "Handshake response not received." When I use the REST api it connects fine and I get no issues. I know that it isn't on the server side because when I run "wscat -c wss://socket.polygon.io/stocks" I connect fine and am authorized each time. I am running JDK 13 and have tried this on JDK 11 and it didn't work. I noticed however that when I run on JDK 8 it works fine. I believe it might be a version compatibility issue.

I know that the web socket library in use is tyrus, and I found out that the repository is no longer supported. On the web I have found that others have had similar issues with later versions of Java and that JDK 8 is the last known working version of Java with tyrus for certain websockets. I don't know enough to understand why, but the alpaca web socket works great on JDK 13. I will attach some photos for reference. Capture

mainstringargs commented 4 years ago

Thanks for pointing this out -- I'm wondering if bumping up the version of tyrus will help us here. It looks like there are newer revs -- https://mvnrepository.com/artifact/org.glassfish.tyrus.bundles/tyrus-standalone-client-jdk -- but its a bit hard to tell if they are "official" or if there is a changelog somewhere. Can you point me to where you're seeing that it is no longer supported?

dallinlarsen commented 4 years ago

I just looked into it some more and I the repository that I found was no longer maintained was at: https://github.com/tyrus-project/tyrus and that the more up to date repository is at: https://github.com/eclipse-ee4j/tyrus. I'm not familiar with tyrus and web sockets, this is the first time I have used them in a project. I'm not sure where the most up to date version will be.

mainstringargs commented 4 years ago

Thanks for the info. I will attempt to replicate tomorrow when the market is open, and see if bumping up to a newer version of tyrus will work out.

mainstringargs commented 4 years ago

I've created a branch & pull request: https://github.com/mainstringargs/alpaca-java/pull/58 For some reason I'm having issues with my alpaca account that I've had to send a message to Alpaca support for which is preventing me from verifying at the moment. Hopefully they get back to me soon..