Skip to content

Instantly share code, notes, and snippets.

@adam-stokes
Created February 12, 2014 01:25
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save adam-stokes/8948180 to your computer and use it in GitHub Desktop.
Save adam-stokes/8948180 to your computer and use it in GitHub Desktop.
python websocket over wss
#!/usr/bin/python3
from ws4py.client.threadedclient import WebSocketClient
from pprint import pprint
import json
params = {}
params['Type'] = "Admin"
params['Request'] = 'Login'
params['RequestId'] = 1
params['Params'] = {'AuthTag': 'user-admin',
'Password': '211fdd69b8942c10cef6cfb8a4748fa4' }
class Stupid(WebSocketClient):
def opened(self):
self.send(json.dumps(params))
def closed(self, code, reason):
print(("Closed", code, reason))
def received_message(self, m):
print(("Message", json.loads(m.data.decode('utf-8'))))
if __name__ == '__main__':
ws = Stupid('wss://10.0.3.1:17070/', protocols=['https-only'])
ws.daemon = False
ws.connect()
info = {'Type': 'Client',
'Request': 'EnvironmentInfo'}
ws.send(json.dumps(info))
ws.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment