8go / matrix-commander

simple but convenient CLI-based Matrix client app for sending and receiving
GNU General Public License v3.0
563 stars 59 forks source link

Solved: Interactive login hangs in docker container #102

Closed ioqy closed 1 year ago

ioqy commented 1 year ago

When only using --login password to login to an account it hangs after entering the URL of the homeserver. I have waited for something like 30 minutes but there was no timeout or something.

With debugging I get the following output:

2022-10-29 08:17:34,420:    DEBUG: matrix-commander: Debug is turned on. debug count=1
2022-10-29 08:17:34,420:    DEBUG: matrix-commander: Separator is set to "    " of length 4. E.g. Col1    Col2.
2022-10-29 08:17:34,421:    DEBUG: matrix-commander: Encryption is always enabled. It cannot be turned off.
2022-10-29 08:17:34,421:    DEBUG: matrix-commander: Option --sync is set to full.
2022-10-29 08:17:34,421:    DEBUG: matrix-commander: All arguments are valid. All checks passed.
2022-10-29 08:17:34,421:    DEBUG: matrix-commander: Create directory /root/.run for PID file.
2022-10-29 08:17:34,421:    DEBUG: matrix-commander: Trying to create a PID file to store process id 1.
2022-10-29 08:17:34,421:    DEBUG: matrix-commander: Successfully created PID file "/root/.run/matrix-commander.b9daea8b-6512-40d7-a11a-79c7858cb142.pid" to store process id 1.
2022-10-29 08:17:34,421:    DEBUG: matrix-commander: Python version is "3.10.7 (main, Sep  7 2022, 00:00:00) [GCC 11.3.1 20220421 (Red Hat 11.3.1-2)]"
2022-10-29 08:17:34,421:    DEBUG: matrix-commander: Stdin pipe is assigned to "none".
2022-10-29 08:17:34,421:    DEBUG: matrix-commander: SSL will be used. Default SSL certificate validation will be done for this connection.
2022-10-29 08:17:34,422:    DEBUG: matrix-commander: Credentials file was specified with full path. So we suggest that one. file: /data/credentials.json
2022-10-29 08:17:34,422:    DEBUG: matrix-commander: Store directory "/data/store" was specified by user, it is a directory with a path, but the directory does not exist.
2022-10-29 08:17:34,422:    DEBUG: matrix-commander: Store directory was not found anywhere. Hence, we will suggest "/data/store" (local directory) as store directory.
2022-10-29 08:17:34,422:    DEBUG: matrix-commander: --login has chosen password method for authentication
Enter URL of your homeserver: [https://matrix.example.org] 

Then I enter https://matrix.org and it just hangs until I press ctrl+c.

I used this method in the past and it worked fine.

Then I found out that I could give the homeserver, username and password as parameter and tried with the parameters --login password --user-login '@example:matrix.org' --password 'example' --homeserver 'https://matrix.org' and get a prompt for a device name. After entering the device name it also hangs. So I try with all the parameters that the password login supports --login password --user-login '@example:matrix.org' --password 'example' --homeserver 'https://matrix.org' --device 'matrix-commander' --room-default '!example:matrix.org' and then it worked fine.

I used the latest version via docker:

matrix-commander: 3.5.23 2022-10-25
matrix-nio: 0.20.0
Python: 3.10.7
8go commented 1 year ago

I just retested for you:

matrix-commander --login password
Enter URL of your homeserver: [https://matrix.example.org] https://matrix.example.org
Enter your user ID:  [@john:example.org]  or  [john] for @john:matrix.example.org : john
Please provide your Matrix account password.
Password: 
Choose a name for this device: [matrix-commander] 
Enter room ID for default room:  [!SomeRoomIdString:example.org]  or  [alias] for #alias:matrix.example.org : alias
2022-11-04 13:00:52,485:     INFO: matrix-commander: The provided login data is: homeserver='https://matrix.example.org'
2022-11-04 13:00:52,485:     INFO: matrix-commander:                             user id='@john:matrix.example.org'
2022-11-04 13:00:52,485:     INFO: matrix-commander:                             device name='matrix-commander'
2022-11-04 13:00:52,485:     INFO: matrix-commander:                             room id='#alias:matrix.example.org'
The provided login data is: homeserver='https://matrix.example.org'
                            user id='@john:matrix.example.org'
                            password='***'
                            device name='matrix-commander'
                            room id='#alias:matrix.example.org'
Correct? (Yes or Ctrl-C to abort) Y
2022-11-04 13:01:17,851:    ERROR: matrix-commander: The program matrix-commander.py failed. Sorry.
2022-11-04 13:01:17,851:    ERROR: matrix-commander: Cannot connect to host matrix.example.org:443 ssl:default [Name or service not known]
2022-11-04 13:01:17,853:     INFO: matrix-commander: 2 errors and 0 warnings occurred.

It works as expected. (It could not connect because I entered a host that does not exist. But it worked just fine.)

Same version:

matrix-commander  --version

  _|      _|      _|_|_|    _|       matrix-commander: 3.5.23 2022-10-25
  _|_|  _|_|    _|            _|     a Matrix CLI client
  _|  _|  _|    _|              _|   enjoy and submit PRs
  _|      _|    _|            _|     matrix-nio: 0.20.0
  _|      _|      _|_|_|    _|       Python: 3.10.7

What OS?

ioqy commented 1 year ago

The underlying OS:

Operating System: Debian GNU/Linux 11 (bullseye)
          Kernel: Linux 5.10.0-19-amd64
    Architecture: x86-64
ioqy commented 1 year ago

It was a problem on my end. I ran the container only with docker run --tty. Adding the --interactive option solved the problem.

Sorry for any inconvenience.

8go commented 1 year ago

OK, glad it is working and you are on your way. :+1: