Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
zahedul opened this issue Mar 6, 2016 · 2 comments

Comments

@zahedul
Copy link

zahedul commented Mar 6, 2016

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

@theblazehen
Copy link

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

@zahedul
Copy link
Author

zahedul commented May 18, 2016

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants