Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
ashmitbhui opened this issue Mar 21, 2018 · 2 comments
Closed

Comments

@ashmitbhui
Copy link

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
Copy link
Contributor

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
Copy link
Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants