parse-community / ParseLiveQuery-Android

Parse LiveQuery client for Android.
Other
84 stars 32 forks source link

Socket onError: Expected HTTP 101 response but was '502 Bad Gateway' #79

Closed ashmitbhui closed 6 years ago

ashmitbhui commented 6 years ago
ParseLiveQueryClient parseLiveQueryClient = null;
        try {
            parseLiveQueryClient = ParseLiveQueryClient.Factory.getClient(new URI("wss://APP-NAME.back4app.io"));
        } catch (URISyntaxException e) {
            e.printStackTrace();
        }
        ParseQuery<ParseObject> parseQuery = ParseQuery.getQuery("Orders");
        SubscriptionHandling<ParseObject> subscriptionHandling = parseLiveQueryClient.subscribe(parseQuery);

        subscriptionHandling.handleEvents(new SubscriptionHandling.HandleEventsCallback<ParseObject>() {
            @Override
            public void onEvents(ParseQuery<ParseObject> query, SubscriptionHandling.Event event, ParseObject object) {
                Toast.makeText(HomeScreen.this, "Subscribed!", Toast.LENGTH_SHORT).show();
            }
        });

Everytime i try to connect i get Socket OnError:

ParseLiveQueryClient: Socket onError java.net.ProtocolException: Expected HTTP 101 response but was '502 Bad Gateway' at okhttp3.internal.ws.RealWebSocket.checkResponse(RealWebSocket.java:216) at okhttp3.internal.ws.RealWebSocket$2.onResponse(RealWebSocket.java:183) at okhttp3.RealCall$AsyncCall.execute(RealCall.java:141) at okhttp3.internal.NamedRunnable.run(NamedRunnable.java:32) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587) at java.lang.Thread.run(Thread.java:818)

mmimeault commented 6 years ago

Hello ashmitbhui, thanks for using LiveQuery in your projects.

Could you validate that your device can reach the server properly. Make sure ssl is supported, try with ws first intead of wss.

A 502 Bad Gateway is normally a problem between the client and the server. Validate your server configuration.

Thanks

ashmitbhui commented 6 years ago

Hi, I figured out the problem, my URL had uppercase characters because of which I was not able to connect to the server.