python-ddp icon indicating copy to clipboard operation
python-ddp copied to clipboard

I am calling meteor method via celery. normally it goes well. but some it shows following error

Open zahedul opened this issue 8 years ago • 2 comments

File "/usr/lib/python2.7/threading.py", line 810, in __bootstrap_inner self.run() File "/usr/lib/python2.7/threading.py", line 763, in run self.__target(*self.__args, **self.__kwargs) File "/usr/local/lib/python2.7/dist-packages/ws4py/websocket.py", line 425, in run self.opened() File "/usr/local/lib/python2.7/dist-packages/DDPClient.py", line 26, in opened self.emit('opened') File "/usr/local/lib/python2.7/dist-packages/pyee/__init__.py", line 113, in emit f(*args, **kwargs) File "/usr/local/lib/python2.7/dist-packages/DDPClient.py", line 148, in opened self.send(connect_msg) File "/usr/local/lib/python2.7/dist-packages/DDPClient.py", line 158, in send self.ddpsocket.send(msg_dict) File "/usr/local/lib/python2.7/dist-packages/DDPClient.py", line 36, in send super(DDPSocket, self).send(message) File "/usr/local/lib/python2.7/dist-packages/ws4py/websocket.py", line 261, in send self._write(m) File "/usr/local/lib/python2.7/dist-packages/ws4py/websocket.py", line 241, in _write raise RuntimeError("Cannot send on a terminated websocket") RuntimeError: Cannot send on a terminated websocket

zahedul avatar Mar 06 '16 08:03 zahedul

Can you pass debug=True when you create the connection? That way we can see if the connection is dropping before you send data.

theblazehen avatar May 06 '16 07:05 theblazehen

My code is:

from DDPClient import DDPClient
from celery import Celery
from celery.utils.log import get_task_logger

import time

logger = get_task_logger(__name__)

isReconnect = True
reconnectTimeOut = 60
isDebug = True 
URL = 'ws://my-url/websocket'

app = Celery('tasks')
app.config_from_object('celeryconfig')

def callback_function(data):
    print('I am here');
    print data

def connected(self):
    print '* CONNECTED'

def closed(code, reason):
    print '* CONNECTION CLOSED {} {}'.format(code, reason)

def reconnected(self):
    print '* RECONNECTED'

def failed(collection, data):
    print '* FAILED - data: {}'.format(str(data))

@app.task
def processScheduleOrder():
    print("start processScheduleOrder")
    logger.info("start processScheduleOrder")

    client = DDPClient(URL, auto_reconnect=isReconnect, auto_reconnect_timeout=reconnectTimeOut, debug=isDebug)

    client.on('connected', connected)
    client.on('socket_closed', closed)
    client.on('reconnected', reconnected)
    client.on('failed', failed)

    client.connect()
    client.call('processScheduleOrder', [])
    client.close()
    logger.info("end processScheduleOrder")

In every 30 min this method call 3 times. Sometimes it connect ddp client successfully. But sometimes it failed, and show error what I share already. If I set debug as true it return same error. I also test callback function. but not luck. What am I missing

Thanks in advance

zahedul avatar May 18 '16 07:05 zahedul