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

disable heartbeat error #256

Open
vatsalmehta1994 opened this issue Mar 24, 2023 · 3 comments
Open

disable heartbeat error #256

vatsalmehta1994 opened this issue Mar 24, 2023 · 3 comments
Labels
asyncblocked When blocking code is used within gevent

Comments

@vatsalmehta1994
Copy link

vatsalmehta1994 commented Mar 24, 2023

Hi,
I am using zerorpc to connect to server. My backend is in python and frontend is in js. Code flashed hex file to MCB chip. When I connect multiple MCBs through PCAN it stops uploading code at random time and gives HeartbeatError: Lost Remote after 10000 ms. I tried changing default HeartbeatInterval from 5000 ms to 10000 ms but it didn't work.

PS: When I try to flash in development mode it flashes all MCBs fine but when I package the code into executable it shows this error.

Can anyone help resolve this issue or disable Heartbeat checks?

Here is the code that connects to server:
Python:

def start_rpc_server():
    address = 'tcp://122.0.0.0:' + str(parse_port())
    cfg_file_name = 'uds_flasher_cfg.json5'
    cfg = load_json5_portable(file=cfg_file_name, mode='r')  # from json configuration file
    server = zerorpc.Server(UpdateUtility(uds_cfg=cfg['uds_cfg'], system_cfg=cfg['system_cfgs'][platform.system()], bl_cfg=cfg['bl_cfg'], user_cfg=cfg['user_cfg']))
    server.bind(address)
    print('start running on {}'.format(address))
    server.run()

JS:

const zerorpc = require("zerorpc");
let client = new zerorpc.Client({ timeout: 2 });
client.connect("tcp://122.0.0.0:4444");
@bombela
Copy link
Member

bombela commented Mar 24, 2023

The blocking under concurrent access most likely means that you have a mismatch between async code running on the gevent ioloop and some blocking code.

As a quick test, replace your service object by some mock that does a gevent.sleep(5) for example, and see how many concurrent request you can run.

I wouldn't surprised that the UpdateUtility is blocking the gevent ioloop.

@bombela bombela added the asyncblocked When blocking code is used within gevent label Mar 24, 2023
@vatsalmehta1994
Copy link
Author

Hey,
Thanks for the response.
I tried adding gevent.sleep(5) in between flashing 2 MCBs but it do the same thing.

@bombela
Copy link
Member

bombela commented Mar 25, 2023

I meant instead of flashing. To show that the flashing operation is most likely a blocking operation. That blocks the current greenlet. In turn blocking the ioloop. You might want to read the documentation of gevent, and more generally about concurrency, parallelism, blocking vs async, and the function coloring problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
asyncblocked When blocking code is used within gevent
Projects
None yet
Development

No branches or pull requests

2 participants