Skip to content

TLS not working: TypeError: sequence item 0: expected str instance, int found when running PageKite #119

Description

@kerbymart

Description
When running PageKite as both frontend and backend, the service encounters a TypeError indicating an unexpected integer in a string operation. The error output is:

TypeError: sequence item 0: expected str instance, int found

Below is the relevant portion of the systemd status log for pagekite.service:

Jan 22 09:27:11 vps-xxxxxx pagekite[22392]:            ^^^^^^^^^^^^^^^^^^^^^^
Jan 22 09:27:11 vps-xxxxxx pagekite[22392]:   File "/usr/lib/python3/dist-packages/pagekite/proto/selectables.py", line 695, in Inbound
Jan 22 09:27:11 vps-xxxxxx pagekite[22392]:     return self.ProcessTls(data)
Jan 22 09:27:11 vps-xxxxxx pagekite[22392]:            ^^^^^^^^^^^^^^^^^^^^^
Jan 22 09:27:11 vps-xxxxxx pagekite[22392]:   File "/usr/lib/python3/dist-packages/pagekite/proto/conns.py", line 1813, in ProcessTls
Jan 22 09:27:11 vps-xxxxxx pagekite[22392]:     self.Send(TLS_Unavailable(unavailable=True), try_flush=True)
Jan 22 09:27:11 vps-xxxxxx pagekite[22392]:   File "/usr/lib/python3/dist-packages/pagekite/proto/selectables.py", line 449, in Send
Jan 22 09:27:11 vps-xxxxxx pagekite[22392]:     pending = ''.join([self.write_blocked, str(''.join(data))])
Jan 22 09:27:11 vps-xxxxxx pagekite[22392]:                                                ^^^^^^^^^^^^^
Jan 22 09:27:11 vps-xxxxxx pagekite[22392]: TypeError: sequence item 0: expected str instance, int found

Steps to Reproduce

  1. Configure PageKite as both a frontend and a backend.

  2. Use the following (simplified) frontend configuration in /etc/pagekite.d/20_frontends.rc:

    isfrontend
    ports=80,443
    
    protos=http,https
    domain=http,https:*.hosting.space:<secret>
    
    tls_endpoint=*.hosting.space:/etc/letsencrypt/live/hosting.space/frontend.pem
  3. Run the backend with a command similar to:

    ./pagekite.py --clean \
    --frontend=hosting.space:443 \
    --service_on=https:coolify.hosting.space:localhost:8000:<secret> \
    --logfile=pagekite.log
  4. Check the service status:

    sudo systemctl status pagekite.service
  5. Observe the TypeError in the logs.


Expected Behavior
PageKite should handle TLS connections without raising a TypeError, successfully passing traffic over HTTP/HTTPS.


Actual Behavior
The PageKite service raises a TypeError indicating that an integer was found where a string was expected, causing an exception in selectables.py.


Additional Information

  • OS: Debian 12 (VPS)
  • PageKite version: (installed from apt / system package repository)
  • IP Address (Obfuscated): xxx.xxx.xxx.xxx
  • Domain: hosting.space
  • Certificates: Let's Encrypt (stored in /etc/letsencrypt/live/hosting.space/)

Commands for reference:

  • sudo systemctl status pagekite.service
  • sudo systemctl restart pagekite.service

If you need more information (e.g., full logs or configuration details), let me know.


Possible Causes / Ideas

  • Mismatch between Python string encoding and integer data in selectables.py.
  • A bug in the TLS handling logic that improperly casts or handles data types.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions