Error running KiteConnect python code on Azure Automation Account

Dear All,

Im running KiteConnect python code on Azure Automation Account

I got following error.
Traceback (most recent call last): File "C:\Temp\vhot3ffk.m43\48bc173a-7a01-4786-b27f-2b1c07c03ee9", line 3, in from kiteconnect import KiteConnect File "C:\WPy64-3800\python-3.8.0.amd64\lib\site-packages\kiteconnect\", line 111, in from kiteconnect.ticker import KiteTicker File "C:\WPy64-3800\python-3.8.0.amd64\lib\site-packages\kiteconnect\", line 18, in from twisted.internet import reactor, ssl File "C:\WPy64-3800\python-3.8.0.amd64\lib\site-packages\twisted\internet\", line 40, in default.install() File "C:\WPy64-3800\python-3.8.0.amd64\lib\site-packages\twisted\internet\", line 192, in install reactor = SelectReactor() File "C:\WPy64-3800\python-3.8.0.amd64\lib\site-packages\twisted\internet\", line 75, in __init__ posixbase.PosixReactorBase.__init__(self) File "C:\WPy64-3800\python-3.8.0.amd64\lib\site-packages\twisted\internet\", line 632, in __init__ self.installWaker() File "C:\WPy64-3800\python-3.8.0.amd64\lib\site-packages\twisted\internet\", line 330, in installWaker self.waker = self._wakerFactory(self) File "C:\WPy64-3800\python-3.8.0.amd64\lib\site-packages\twisted\internet\", line 127, in __init__ server.listen(1)OSError: [WinError 10050] A socket operation encountered a dead network

Anyone faced this issue?
  • rakeshr
    OSError: [WinError 10050] A socket operation encountered a dead network
    It means, the issue with your server network system. This article, explains on the issue.
  • ashxos
    Hey Rakesh,

    Im doing troubleshooting on this issue. I have kept following minimul code on the app.
    from kiteconnect import KiteConnect
    from kiteconnect import KiteConnect
    Zerodha_API_KEY = "XXXXXX"
    kite = KiteConnect(api_key=Zerodha_API_KEY)
    Fyers API is working on the same application without any issue. I have just added the Zerodha module on top of it. After that this issue has started. There is no issue with the network connection for the application as Fyers API is working smooth.

    Im still troubleshooting from my side. If possible please check the same from your side on the Azure Linux WebApp (Free Tier).
  • ashxos
    Current Error on Azure Python Linux WebApp. I have mixed two platform in this single thread.

    The first error submitted is of Azure Automation Account
    The below error is of Azure Python Linux WebApp
    2021-07-15T11:12:09.280292471Z _____
    2021-07-15T11:12:09.280304271Z / _ \ __________ _________ ____
    2021-07-15T11:12:09.280311872Z / /_\ \___ / | \_ __ \_/ __ \
    2021-07-15T11:12:09.280319472Z / | \/ /| | /| | \/\ ___/
    2021-07-15T11:12:09.280326672Z \____|__ /_____ \____/ |__| \___ >
    2021-07-15T11:12:09.280334173Z \/ \/ \/
    2021-07-15T11:12:09.280348073Z A P P S E R V I C E O N L I N U X
    2021-07-15T11:12:09.280361474Z Documentation:
    2021-07-15T11:12:09.280368174Z Python 3.8.6
    2021-07-15T11:12:09.280374875Z Note: Any data outside '/home' is not persisted
    2021-07-15T11:12:09.654320473Z Starting OpenBSD Secure Shell server: sshd.
    2021-07-15T11:12:09.739608672Z App Command Line not configured, will attempt auto-detect
    2021-07-15T11:12:09.740706500Z Launching oryx with: create-script -appPath /home/site/wwwroot -output /opt/startup/ -virtualEnvName antenv -defaultApp /opt/defaultsite
    2021-07-15T11:12:09.871149910Z Found build manifest file at '/home/site/wwwroot/oryx-manifest.toml'. Deserializing it...
    2021-07-15T11:12:09.881601967Z Build Operation ID: |8ufRzjfGT4Q=.9903ac7b_
    2021-07-15T11:12:09.890669690Z Oryx Version: 0.2.20210420.1, Commit: 85c6e9278aae3980b86cb1d520aaad532c814ed7, ReleaseTagName: 20210420.1
    2021-07-15T11:12:09.891252705Z Output is compressed. Extracting it...
    2021-07-15T11:12:09.895295404Z Extracting '/home/site/wwwroot/output.tar.gz' to directory '/tmp/8d94707cb81be1f'...
    2021-07-15T11:12:14.577736859Z App path is set to '/tmp/8d94707cb81be1f'
    2021-07-15T11:12:16.276763516Z Detected an app based on Flask
    2021-07-15T11:12:16.278429174Z Generating `gunicorn` command for 'app:app'
    2021-07-15T11:12:16.836063591Z Writing output script to '/opt/startup/'
    2021-07-15T11:12:17.568867477Z Using packages from virtual environment antenv located at /tmp/8d94707cb81be1f/antenv.
    2021-07-15T11:12:17.569943514Z Updated PYTHONPATH to ':/tmp/8d94707cb81be1f/antenv/lib/python3.8/site-packages'
    2021-07-15T11:12:17.674962252Z Traceback (most recent call last):
    2021-07-15T11:12:17.675003253Z File "/opt/python/3.8.6/bin/gunicorn", line 3, in <module>
    2021-07-15T11:12:17.675027254Z import re
    2021-07-15T11:12:17.675036154Z File "/opt/python/3.8.6/lib/python3.8/", line 145, in <module>
    2021-07-15T11:12:17.675044155Z class RegexFlag(enum.IntFlag):
    2021-07-15T11:12:17.675051755Z AttributeError: module 'enum' has no attribute 'IntFlag'
    2021-07-15T11:12:25.447Z ERROR - Container rocketzerodha_0_7bea6f30 for site rocketzerodha has exited, failing site start
    2021-07-15T11:12:25.461Z ERROR - Container rocketzerodha_0_7bea6f30 didn't respond to HTTP pings on port: 8000, failing site start. See container logs for debugging.
    2021-07-15T11:12:25.475Z INFO - Stopping site rocketzerodha because it failed during startup.
  • ashxos
    Updated Source Code with Flask WebApp. Still same error.
        from flask import Flask, request
    from kiteconnect import KiteConnect

    app = Flask(__name__)

    def index():
    Zerodha_API_KEY = "XXXXXXXXXX"
    Zerodha_Access_Token= "XXXXXXXXXXX"
    kite = KiteConnect(api_key=Zerodha_API_KEY)
    data = kite.orders()
    return str(data)
  • ashxos

    I have found one interesting dependancy conflict.

    This image shows that enum34 is required by KiteConnect. Many forums are saying that uninstall the enum to rectify the issue. Also I have got some articals saying that enum34 is no longer required post Python 3.6.

    Can you please check the enum34 dependacy on your KiteConnect? If not required, can you please remove the dependancy of enum34 from your package?

  • rakeshr
    We are checking on this. But, will this release will take some time, as we will be releasing this as a major breaking- release along with a few up-gradation already in the queue.
    For now, you can fork our pykiteconnect repo, create a new branch which will have enum32 removed from dependencies in the setup file. Then install specific branch using below pip command on your server. Something like:
    pip install git+git://[email protected](branch name for enum32 removed)
  • ashxos
    Hi Rakesh,

    As Azure WebApp installs the requirement using requirements.txt, i dont have option to use custom repo.

    Im in contact with Microsoft support for this. Will keep you posted.

    Meanwhile, can you please check porting a simple code on Azure Linux WebApp(Free) from your side?
Sign In or Register to comment.