Skip to content
This repository has been archived by the owner on May 17, 2021. It is now read-only.

New IRCCloud server (tinside) fails to keep session alive #2

Open
TehPeGaSuS opened this issue Mar 11, 2021 · 13 comments
Open

New IRCCloud server (tinside) fails to keep session alive #2

TehPeGaSuS opened this issue Mar 11, 2021 · 13 comments
Assignees
Labels
bug Something isn't working

Comments

@TehPeGaSuS
Copy link
Contributor

TehPeGaSuS commented Mar 11, 2021

When you run irccloud.py, the session isn't kept alive but no explicit error is shown.

2021-03-11 08:58:43,911 INFO     Successfully obtained authentication token.
2021-03-11 08:58:44,613 INFO     Successfully obtained a session id.
2021-03-11 08:58:45,029 ERROR    IRC Cloud Session could not be Kept alive.

If you need more debug, let me know the commands you'd like me to run.
All the other servers seem to work as expected, but they'll be probably affected by this issue some time later.
Cheers

@vijaiaeroastro
Copy link
Owner

I would have to test this. I never run it personally on my machine.

@vijaiaeroastro
Copy link
Owner

The issue seems to happen because of something fishy in environmental variables. Just hardcode username and password in your irccloud.py file and it should work.

@vijaiaeroastro vijaiaeroastro added the bug Something isn't working label Mar 13, 2021
@vijaiaeroastro vijaiaeroastro self-assigned this Mar 13, 2021
@TehPeGaSuS
Copy link
Contributor Author

I've tried hardcoding and it doesn't seem to work...

Working (highgate server)

$ cd irccloud.self; IRCCLOUD_USERNAME="<redacted_1>" IRCCLOUD_PASSWORD="password" python3 /home/irccloud/irccloud.self/irccloud.py; cd
2021-03-13 17:50:45,103 INFO Successfully obtained authentication token.
2021-03-13 17:50:45,874 INFO Successfully obtained a session id.
2021-03-13 17:50:56,311 INFO IRC Cloud Session is Kept alive.

Not working (tinside server)

$ cd irccloud.self; IRCCLOUD_USERNAME="<redacted_2>" IRCCLOUD_PASSWORD="password" python3 /home/irccloud/irccloud.self/irccloud.py; cd
2021-03-13 17:42:40,579 INFO Successfully obtained authentication token.
2021-03-13 17:42:41,330 INFO Successfully obtained a session id.
2021-03-13 17:42:41,730 ERROR IRC Cloud Session could not be Kept alive.

With the following irccloud.py changes

if __name__ == "__main__":
    try:
        email = "<redacted_2>"
        password = "password"
        irc = irccloud(email, password)
        irc.runner()
    except KeyboardInterrupt:
        self.log.debug("Shutdown requested. Exiting script. Thank you :)")
        sys.exit(0)
    except Exception:
        traceback.print_exc(file=sys.stdout)
        sys.exit(0)

~/irccloud.self$ python3 irccloud.py
2021-03-13 17:59:13,501 INFO Successfully obtained authentication token.
2021-03-13 17:59:14,260 INFO Successfully obtained a session id.
2021-03-13 17:59:14,642 ERROR IRC Cloud Session could not be Kept alive.

@vijaiaeroastro
Copy link
Owner

I have gone through their android app source code. Authentication mechanism remains to be the same. They haven't changed anything. If on their API side, they changed something, i am not sure. In that case, maybe for the server where it fails, can you print the actual raw api output and paste ? Wherever you see the line

response = r.json()

Include an additional line that prints this response and share the output.

@TehPeGaSuS
Copy link
Contributor Author

In that case, maybe for the server where it fails, can you print the actual raw api output and paste ? Wherever you see the line

response = r.json()

How do I do this?

@vijaiaeroastro
Copy link
Owner

vijaiaeroastro commented Mar 21, 2021

Just do

print(response)

after that line

@alimaqsood
Copy link

{'success': True, 'token': '1616400772.f3d2662d0c9615d69a98adc60c570b57'}
2021-03-22 08:12:52,423 INFO Successfully obtained authentication token.
2021-03-22 08:12:52,959 INFO Successfully obtained a session id.
2021-03-22 08:12:53,203 ERROR IRC Cloud Session could not be Kept alive.

@vijaiaeroastro
Copy link
Owner

@PeGaSuS-Coder @alimaqsood
I guess you guys don't have a basic Python knowledge. I have modified the script now.
Check line 110 towards the end
It says
debug_mode=False
Change this to
debug_mode=True
and run the script and share the output here

@alimaqsood
Copy link

{'success': True, 'token': '1616405147.d028c6da69890a500fc1ba8bc6cef2d9'}
2021-03-22 09:25:47,117 INFO Successfully obtained authentication token.
{'success': True, 'session': '6.1f9b837aed0a8ac383f9ae7a92a7cf4d', 'uid': 22365, 'api_host': 'https://api-6.irccloud.com', 'websocket_host': 'api-6.irccloud.com', 'websocket_path': '/websocket/6', 'url': ''}
2021-03-22 09:25:47,689 INFO Successfully obtained a session id.
{'success': False, 'message': 'set_shard', 'shard_id': 6, 'api_host': 'https://api-6.irccloud.com', 'websocket_host': 'api-6.irccloud.com', 'websocket_path': '/websocket/6', 'cookie': '6.1f9b837aed0a8ac383f9ae7a92a7cf4d'}
2021-03-22 09:25:47,924 ERROR IRC Cloud Session could not be Kept alive.

@TehPeGaSuS
Copy link
Contributor Author

TehPeGaSuS commented Apr 21, 2021

Exactly the same issue:

{'success': True, 'token': '1619022771.7491bbb97e662c12012d7d4df2ea55e5'}
2021-04-21 18:32:52,101 INFO     Successfully obtained authentication token.
{'success': True, 'session': '6.1e6f3269366a8180a203fff0e2a3a76f', 'uid': 165061, 'api_host': 'https://api-6.irccloud.com', 'websocket_host': 'api-6.irccloud.com', 'websocket_path': '/websocket/6', 'url': ''}
2021-04-21 18:32:53,326 INFO     Successfully obtained a session id.
{'success': False, 'message': 'set_shard', 'shard_id': 6, 'api_host': 'https://api-6.irccloud.com', 'websocket_host': 'api-6.irccloud.com', 'websocket_path': '/websocket/6', 'cookie': '6.1e6f3269366a8180a203fff0e2a3a76f'}
2021-04-21 18:32:53,742 ERROR    IRC Cloud Session could not be Kept alive.

@TehPeGaSuS
Copy link
Contributor Author

Unfortunately, when trying debug mode with a successful keep alive for comparison, I got the following errors:

{'success': True, 'token': '1619023522.94d4f4a8890378ac227f89299b75ee7a'}
2021-04-21 18:45:22,597 INFO     Successfully obtained authentication token.
{'success': True, 'session': '1.214e6e88190fec2bf2a48d8aa54e6584', 'uid': 376365, 'api_host': 'https://api-1.irccloud.com', 'websocket_host': 'api-1.irccloud.com', 'websocket_path': '/websocket/1', 'url': ''}
2021-04-21 18:45:23,309 INFO     Successfully obtained a session id.
Traceback (most recent call last):
  File "/home/irccloud/irccloud.self/irccloud.py", line 112, in <module>
    irc.runner()
  File "/home/irccloud/irccloud.self/irccloud.py", line 99, in runner
    self.keep_alive()
  File "/home/irccloud/irccloud.self/irccloud.py", line 86, in keep_alive
    print(r.json())
  File "/usr/local/lib/python3.8/dist-packages/requests/models.py", line 900, in json
    return complexjson.loads(self.text, **kwargs)
  File "/usr/lib/python3/dist-packages/simplejson/__init__.py", line 518, in loads
    return _default_decoder.decode(s)
  File "/usr/lib/python3/dist-packages/simplejson/decoder.py", line 373, in decode
    raise JSONDecodeError("Extra data", s, end, len(s))
simplejson.errors.JSONDecodeError: Extra data: line 2 column 1 - line 5 column 1 (char 140 - 2733)

Cheers

@MeowMeowVenom
Copy link

Same issue here too

{'success': True, 'token': '1619933913.285476029002eaf63a88fa0492ee87a3'}
2021-05-02 11:08:33,520 INFO     Successfully obtained authentication token.
{'success': True, 'session': '6.ac6c3cd5ea6b53918d8dd9b4671b6843', 'uid': 478872, 'api_host': 'https://api-6.irccloud.com', 'websocket_host': 'api-6.irccloud.com', 'websocket_path': '/websocket/6', 'url': ''}
2021-05-02 11:08:34,371 INFO     Successfully obtained a session id.
{'success': False, 'message': 'set_shard', 'shard_id': 6, 'api_host': 'https://api-6.irccloud.com', 'websocket_host': 'api-6.irccloud.com', 'websocket_path': '/websocket/6', 'cookie': '6.ac6c3cd5ea6b53918d8dd9b4671b6843'}
2021-05-02 11:08:34,871 ERROR    IRC Cloud Session could not be Kept alive.

@vijaiaeroastro
Copy link
Owner

Hey everybody,

Finally the issue is clear. It seems like IRCCloud disable HTTP based authentication and prefer a streaming request using their websocket API.

You can track the progress here
vijaiaeroastro/irccloud#10

Once we have a working solution in the automated repository, i will update the same here.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants