Why do I not execute the real-time data when I use HTTPS domain name and the real-time data when I use IP address?

Why do I not execute the real-time data when I use HTTPS domain name and the real-time data when I use IP address?

Hi @CollinsWalker, welcome to the community!

I noticed that you opened an issue for this in the Android SDK - #1015. Please can you refrain from cross-posting as it can waste the time of others.

We really need a lot more information to be able to help with this…

  1. Which SDK(s) are you using? - Android SDK and/or Android Live Query
  2. Can you provide the relevant code? - such as the query you are trying to execute
  3. Could you provide more detail about what you are trying to achieve, I’m struggling to understand your question.
ParseLiveQueryClient parseLiveQueryClient = ParseLiveQueryClient.Factory.getClient();
        //mPosts.clear();
        ParseQuery<Post> query = ParseQuery.getQuery(Post.class);
        // Connect to Parse server
        SubscriptionHandling<Post> subscriptionHandling = parseLiveQueryClient.subscribe(query);
        // Listen for CREATE events
        subscriptionHandling.handleEvent(SubscriptionHandling.Event.CREATE, new SubscriptionHandling.HandleEventCallback<Post>() {
            @Override
            public void onEvent(ParseQuery<Post> query, Post object) {
                //mPosts.add(0, object);
                Handler handler = new Handler(Looper.getMainLooper());
                handler.post(new Runnable() {
                    @Override
                    public void run() {
                        //adapter.notifyDataSetChanged();
                        //recyclerView.scrollToPosition(0);
                        initData();
                    }
                });
            }
        });

This is my real-time code

If I change the link in parse. Initialize… server() to HTTPS: / / domain name, the real-time data will not be realized, and if I change to IP, the real-time data can run successfully. My English is not good so the description is not very good. Sorry.

It is probably something related to your Parse Server deployment. Can you describe where/how you are deploying the Parse Server?

If you construct your live query client like this, you will be able to see more details of the failure in Logcat.

HttpLoggingInterceptor logging = new HttpLoggingInterceptor();
logging.setLevel(Level.BODY);
OkHttpClient client = new OkHttpClient.Builder()
  .addInterceptor(logging)
  .build();
OkHttp3SocketClientFactory socketFactory = new OkHttp3SocketClientFactory(client);
ParseLiveQueryClient parseLiveQueryClient = ParseLiveQueryClient.Factory.getClient(socketFactory);
// the rest of your code

This will output all network activity to your Logcat, including potential errors. But yes, like @davimacedo said, this is likely an error on the server deployment.

I deployed in CentOS 7 with node version of 12.16.1 and mongodb version of 4.0.10. I didn’t know there was an error there

OK, I’ll try. Thank you for your answer

  var api = new ParseServer({
  databaseURI: databaseUri || 'mongodb://localhost:27017/parse',
  cloud: process.env.CLOUD_CODE_MAIN || __dirname + '/cloud/main.js',
  appId: process.env.APP_ID || 'appId',
  masterKey: process.env.MASTER_KEY || 'masterKey', //Add your master key here. Keep it secret!
  serverURL: process.env.SERVER_URL || 'https://app.sharequick.cn/parse',  // Don't forget to change to https if needed
  liveQuery: {
    classNames: ["Post", "Comment", "Notification"] // List of classes to support for query subscriptions
  }
});
// Client-keys like the javascript key or the .NET key are not necessary with parse-server
// If you wish you require them, you can set them as options in the initialization above:
// javascriptKey, restAPIKey, dotNetKey, clientKey

 
var dashboard = new ParseDashboard({
	"apps": [
		{
			"serverURL": "https://app.sharequick.cn/parse",
			"appId": "appId",
			"masterKey": "masterKey",
			"appName": "appName"
		}
	],
	"users": [
		{
			"user": "user",
			"pass": "pass"
		}
	],
	"useEncryptedPasswords": false
}, {"allowInsecureHTTP": true});
 
var app = express();
 
// make the Parse Dashboard available at /dashboard
app.use('/dashboard', dashboard);
 
// Serve static assets from the /public folder
app.use('/public', express.static(path.join(__dirname, '/public')));
 
// Serve the Parse API on the /parse URL prefix
var mountPath = process.env.PARSE_MOUNT || '/parse';
app.use(mountPath, api);
 
// Parse Server plays nicely with the rest of your web routes
app.get('/', function(req, res) {
  res.status(200).send('I dream of being a website.  Please star the parse-server repo on GitHub!');
});
 
// There will be a test page available on the /test path of your server url
// Remove this before launching your app
app.get('/test', function(req, res) {
  res.sendFile(path.join(__dirname, '/public/test.html'));
});
 
var port = process.env.PORT || 1337;
var httpServer = require('http').createServer(app);
httpServer.listen(port, function() {
    console.log('parse-server-example running on port ' + port + '.');
});
 
// This will enable the Live Query real-time server
ParseServer.createLiveQueryServer(httpServer);

This is the content of index.js file of my parse server

I still haven’t found the mistake