使用:
我在网页上使用ActionCable,它在rails中工作正常,现在尝试使用https://github.com/tobiasfeistmantl/python-actioncable-zwei来连接python。ActionCableZwei - 用于Rails的Python 3客户端'行动电缆
以下连线成功连接:
connection = Connection(url='ws://localhost:4000/cable', origin='http://localhost:4000/')
我在rails中获得了正确的日志。
现在,我想发送带有套接字的cookie,但是下面的行无法连接,也没有在rails中获取任何日志。
connection = Connection(url='ws://localhost:4000/cable', origin='http://localhost:4000/', log_ping=False, cookie=coo)
还尝试使用log_ping为True / False
以下是我正在尝试的完整代码:
from actioncable.connection import Connection
from actioncable.subscription import Subscription
from actioncable.message import Message
import datetime
import random
from time import sleep
import Cookie
coo = Cookie.SimpleCookie()
coo["fig"] = "newton"
coo["sugar"] = "wafer"
# connection = Connection(url='ws://localhost:4000/cable', origin='http://localhost:4000/')
connection = Connection(url='ws://localhost:4000/cable', origin='http://localhost:4000/', cookie=coo)
connection.connect()
subscription = Subscription(connection, identifier={'channel': 'TestChannel'})
subscription.create()
sleep(30)
subscription.remove()
connection.disconnect()
我只是没有获得有关尝试连接的任何ping / log in rails。我该如何解决这个问题?