Jupyter notebook does not connect to custom kernel


I have a custom jupyter kernel written. The kernel as such seems to work OK because I can test it by starting it from the command line like so python3 -m kernelname and eventually execute commands. But the notebook just doesn’t connect. It appears to enter an infinite loop of connecting to the kernel due to websocket connection failure. Attached is the error on the console.

There were few forum threads where a similar issue was resolved by downgrading tornado to 5.1.1. The version of tornado in my setup is 5.1.1 right now, but the issue continues to persist.

Can someone help me troubleshoot this and arrive at a resolution please?

Thank you.