parse-community / ParseLiveQuery-Android

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

Expected HTTP 101 response but was '403 Forbidden' #94

Closed memishood closed 5 years ago

memishood commented 5 years ago

I use a remote http parse server (2.8.4 parse server version) - (Google cloud compute engine - windows server 2016) and i created a custom Posts class on Dashboard and i tried LiveQuery for Android, i saved any object to Post class but LiveQuery didn't worked

App class:

` val configuration = Parse.Configuration.Builder(this) .applicationId(getString(R.string.parse_server_app_id)) .clientKey(null) .server(getString(R.string.parse_server_url)) .build()

    Parse.initialize(configuration)

` manifest application: name = ".App"

MainActivity: ` val parseLiveQueryClient: ParseLiveQueryClient = ParseLiveQueryClient.Factory.getClient() // when i tried getClient(URI("ws://185.*.*.:1337/")) it gives Expected HTTP 101 response but was '404 Not Found' val parseQuery: ParseQuery = ParseQuery.getQuery("Posts") val subscriptionHandling = parseLiveQueryClient.subscribe(parseQuery)

    subscriptionHandling.handleEvents { query, event, objects ->
        Log.d("onHandleEvents",objects.getString("Message")) // i created two column Message and Sub in Posts class
    }

    subscriptionHandling.handleError { _, exception ->
        Log.d("onError",exception.localizedMessage)
    }

Handler().postDelayed(Runnable { Log.d(this.tag,"Started push") val pObject = ParseObject.create("Posts") pObject.put("Sub","Hello") pObject.put("Message","There!") pObject.saveInBackground() },5000) Server side: var api = new ParseServer({ databaseURI: databaseUri || 'mongodb://*, cloud: process.env.CLOUD_CODE_MAIN || __dirname + '/cloud/main.js', appId: process.env.APP_ID || 'tjlF', masterKey: process.env.MASTER_KEY || 'fg**', serverURL: process.env.SERVER_URL || 'http://localhost:1337/parse', liveQuery: { classNames: ['Posts', 'Comments'] // List of classes to support for query subscriptions } }); var httpServer = require('http').createServer(app); httpServer.listen(port, function() { console.log('parse-server-example running on port ' + port + '.'); }); ParseServer.createLiveQueryServer(httpServer); `

it gives Expected HTTP 101 response but was '403 Forbidden' for response when i tried LiveQuery, anyone can help me ?

mmimeault commented 5 years ago

Did you find the solution?

memishood commented 5 years ago

Yes, when i run the server i used to npm start so it's generate a new index.js as your config.json keys, i was thinking its same with node index.js, i use node index.js and no problem anymore, thank you