Skip to content

Validate port is integer type for SocketPool #78

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 26, 2021

Conversation

brentru
Copy link
Member

@brentru brentru commented Mar 26, 2021

While ESP32-SPI's socket validates if a user passes an invalid port value:

code.py output:
Connecting to WiFi...
Connected!
Connecting to Adafruit IO...
Traceback (most recent call last):
  File "code.py", line 105, in <module>
  File "/lib/adafruit_minimqtt/adafruit_minimqtt.py", line 437, in connect
  File "/lib/adafruit_minimqtt/adafruit_minimqtt.py", line 240, in _get_connect_socket
  File "/lib/adafruit_esp32spi/adafruit_esp32spi_socket.py", line 42, in getaddrinfo
RuntimeError: Port must be an integer

#76 found that native socketpool does not validate port data type before connecting. When entering the port # in the secrets.py file, it may be not clear to people that port requires an integer value while most other values within the file require a string value.

This pull request mirrors ESP32SPI's RuntimeError thrown when using a string as a port number into this library:

code.py output:
Connecting to WiFi...
Connected!
Connecting to Adafruit IO...
Traceback (most recent call last):
  File "code.py", line 105, in <module>
  File "/lib/adafruit_minimqtt/adafruit_minimqtt.py", line 440, in connect
  File "/lib/adafruit_minimqtt/adafruit_minimqtt.py", line 226, in _get_connect_socket
RuntimeError: Port must be an integer

@brentru brentru requested a review from a team March 26, 2021 15:48
@brentru brentru merged commit 0f1205f into adafruit:master Mar 26, 2021
adafruit-adabot added a commit to adafruit/Adafruit_CircuitPython_Bundle that referenced this pull request Apr 3, 2021
Updating https://github.com/adafruit/Adafruit_CircuitPython_SI5351 to 1.2.7 from 1.2.6:
  > Merge pull request adafruit/Adafruit_CircuitPython_SI5351#19 from thefloe1/master
  > "Increase duplicate code check threshold "

Updating https://github.com/adafruit/Adafruit_CircuitPython_MiniMQTT to 5.0.6 from 5.0.5:
  > Merge pull request adafruit/Adafruit_CircuitPython_MiniMQTT#80 from makermelissa/master
  > Merge pull request adafruit/Adafruit_CircuitPython_MiniMQTT#78 from brentru/validate-port
  > "Increase duplicate code check threshold "

Updating https://github.com/adafruit/Adafruit_CircuitPython_PortalBase to 1.5.1 from 1.4.1:
  > Merge pull request adafruit/Adafruit_CircuitPython_PortalBase#27 from makermelissa/main
  > Merge pull request adafruit/Adafruit_CircuitPython_PortalBase#26 from makermelissa/main
  > Merge pull request adafruit/Adafruit_CircuitPython_PortalBase#25 from makermelissa/main
  > "Increase duplicate code check threshold "
rtwfroody pushed a commit to rtwfroody/Adafruit_CircuitPython_MiniMQTT that referenced this pull request Sep 18, 2022
Validate port is integer type for SocketPool
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants