@Ventura_23

В чем ошибка в подключении через pusherclient к websocket?

Помогите решить проблему с подключением. Сделал все как в описании, но не работает...
В чем ошибка? Может чего не хватает?

import pusherclient
import json
import time
import sys
import logging

global pusher

root = logging.getLogger()
root.setLevel(logging.INFO)
ch = logging.StreamHandler(sys.stdout)
root.addHandler(ch)

def connect_handler(data):
	channel = pusher.subscribe('inventory_changes')
	channel.bind('listed', callback=get_info)

def get_info(data):
	print(json.dumps(data, separators=(',', ':')))

pusher = pusherclient.Pusher('c0eef4118084f8164bec65e6253bf195', port=443)
pusher.connection.bind('connected', connect_handler)

pusher.connect()

while True:
	time.sleep(1)


Исходный код на node.js

// first, install the pusher-client library via "npm install pusher-client@1.1.0"

var Pusher = require('pusher-client');

var pusher = new Pusher('c0eef4118084f8164bec65e6253bf195', {
        encrypted: true,
        wsPort: 443,
        wssPort: 443,
        host: 'notifier.bitskins.com'
    });

pusher.connection.bind('connected', function() {
        // connected to realtime updates 
        console.log(" -- connected to websocket");
    });

pusher.connection.bind('disconnected', function() {
        // not connected to realtime updates
        console.log(" -- disconnected from websocket");
    });

var events_channel = pusher.subscribe(CHANNEL); // use the relevant channel, see docs below

events_channel.bind(EVENT_TYPE, function(data) {
        // use the relevant event type, see docs below
        // print out any data received for the given event type
        console.log(" -- got data: " + JSON.stringify(data));
    });
  • Вопрос задан
  • 142 просмотра
Пригласить эксперта
Ответы на вопрос 1
@dvitaha
я тоже пытаюсь разобраться с вебсокетами для подключения к битскинсу)) Получилось, начал изучение питона для этого, чет сложно оказалось!
Ответ написан
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы