socketio / socket.io-client-java

Full-featured Socket.IO Client Library for Java, which is compatible with Socket.IO v1.0 and later.
https://socketio.github.io/socket.io-client-java/installation.html
Other
5.33k stars 975 forks source link

SocketIO-client not responding on https #467

Closed farhansharifkhokhar closed 3 years ago

farhansharifkhokhar commented 6 years ago

Hi Guys, I am trying to get response / real time data from a server. Please review the below code and let me know why I am unable to print socket response that I am getting from URL.

public void printSocketResponse() {
    try {
        URI uri = new URI("https://ws-api.iextrading.com/1.0/tops");
        opts.path = "socket.io-client";

        socket = IO.socket(uri, opts);

    } catch (URISyntaxException e) {
        e.printStackTrace();
    }
    socket.on(Socket.EVENT_CONNECT, new Emitter.Listener() {

        @Override
        public void call(Object... args) {
            System.out.println("Connected");
            socket.emit("subscribe", "firehose");
            socket.disconnect();
        }

    }).on("subscribe", new Emitter.Listener() {

        @Override
        public void call(Object... args) {
            Gson gson = new Gson();
            JsonObject object = gson.fromJson(args[0].toString(), JsonObject.class);

            System.out.println(object.toString());

        }

    }).on(Socket.EVENT_DISCONNECT, new Emitter.Listener() {

        @Override
        public void call(Object... args) {

        }

    });
    socket.connect();
    socket.emit("subscribe", "firehose");
}
shuboy2014 commented 6 years ago

@farhansharifkhokhar I am facing the same problem, do you have any solution?

farhansharifkhokhar commented 6 years ago

Ping me on my person id. farhansharifkhokhar@gmail.com

On 7 Nov 2017 18:01, "Shubham Aggarwal" notifications@github.com wrote:

@farhansharifkhokhar https://github.com/farhansharifkhokhar I am facing the same problem, do you have any solution?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/socketio/socket.io-client-java/issues/467#issuecomment-342475109, or mute the thread https://github.com/notifications/unsubscribe-auth/AeKawHqs4Wwk34drJCpqJhE66bCJ-PMuks5s0FSKgaJpZM4P_uwQ .

danrudolf1 commented 6 years ago

@farhansharifkhokhar Same issue for me. I have setup a Lets Encrypt certificate on my nginx proxy. I connect with an android and iOS app and I had no problems on http, but as soon as the cert was added my android client fails with xhr polling timeout. My iOS client still works with no issues. Were you able to solve this?

sramilli commented 6 years ago

Hi, on EVENT_CONNECT you do a socket.disconnect(); Maybe thats the problem

PhonegapProjects commented 6 years ago

I am facing same issue any solution for the same

Name-less commented 5 years ago

Someone find a solution for this ?

darrachequesne commented 3 years ago

Closed due to inactivity, please reopen if needed.