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

`create_tweet` is throwing Connection Error

Open KunalSin9h opened this issue 1 year ago • 5 comments

I am not able to tweet. I have a script (main.py) to tweet 3 times a day and after tweeting single time api.create_tweet throw ConnectionError.

Screenshot from 2022-10-12 14-11-21

KunalSin9h avatar Oct 12 '22 08:10 KunalSin9h

You may check the network to connect the twitter services.:)

MerleLiuKun avatar Oct 14 '22 07:10 MerleLiuKun

you mean internet ?

KunalSin9h avatar Oct 14 '22 07:10 KunalSin9h

yes, you can check it.

MerleLiuKun avatar Oct 14 '22 08:10 MerleLiuKun

it is running on Azure vm. i have fix this by re trying to tweet when it throws error. see.

        try:
            api.create_tweet(text=hero_text)
        except:
            print(f"on verse: {current_verse_id} at  create_tweet something went wrong, Retrying again...   -    {time.strftime('%X %x %Z')}")
            try:
                api.create_tweet(text=hero_text)
            except:
                print(f"Fail again!  - {time.strftime('%X %x %Z')}")
            else:
                print(f"Tweet Send on second try for verse {current_verse_id}   -    {time.strftime('%X %x %Z')}")
        else:
            print(f"Tweet Send for verse {current_verse_id}   -   {time.strftime('%X %x %Z')}")

it works on trying again just after exception. Internet is not the problem. image

KunalSin9h avatar Oct 14 '22 08:10 KunalSin9h

I have test some tweets, and not found this issue, I guess there may have some connection errors on the vm. :)

MerleLiuKun avatar Oct 14 '22 10:10 MerleLiuKun