Search code examples
meteorwebsocketddp

How do I find the wss URL for a meteor-deployed app?


I'm trying to connect via DDP to my meteor-deployed website at http://testsock.meteor.com . This other answer has been very helpful, but I'm having trouble finding what my URL is, which according to that answer should have the following structure:

ws://ddp--xxxx-{host name}.meteor.com

How do you find out?

My meteor.js file is:

if (Meteor.isClient) {
    }

    if (Meteor.isServer) {
      Meteor.startup(function () {
        // code to run on server at startup
      });

      Meteor.methods({
        test: function(){
          return 5;
        }
      });
    }

I'm using pyddp, and my python file to ddp into mywebsite is:

    import ddp
    import time
    import sys

    client = ddp.ConcurrentDDPClient('wss://testsock.meteor.com:443/websocket')
    client.start()

    while True:
        try:
            time.sleep(1)
            future = client.call('test')
            result_message = future.get()
            if result_message.has_result():
                print 'Result:', result_message.result
            if result_message.has_error():
                print 'Error:', result_message.error

        except KeyboardInterrupt:
            sys.exit()
            client.stop()
            client.join()
            break

Solution

  • When connecting to an app that is deployed to meteor.com, you can use the following URL scheme:

    wss://myapp.meteor.com:443/websocket

    wss denotes the encrypted WebSocket protocol URI scheme, and it is run on port 443.