Replies: 2 comments
-
Interesting issue. I tried your code (the problematic bound variable version) on a Raspberry Pico W also on an ESP32-S3 and it worked without lockups You may have found an ESP8266 bug here. |
Beta Was this translation helpful? Give feedback.
-
I ran your test script on an ESP8266 with >>>
MPY: soft reboot
MicroPython v1.24.0-preview.112.g154813297.dirty on 2024-07-18; ESP8266 with ESP8266
>>> The only change I made is to add "self._connect.send(b'hello from two\n')" after "self.handle_request(self._connect)" so that the connected client gets a response. I have tried with three different types of clients: $ curl --http0.9 192.168.4.98 80
hello from two
^C $ telnet 192.168.4.98 80
Trying 192.168.4.98...
Connected to 192.168.4.98.
Escape character is '^]'.
hello from two
Connection closed by foreign host. $ wget 192.168.4.98 80
--2024-08-02 17:35:14-- http://192.168.4.98/
Connecting to 192.168.4.98:80... connected.
HTTP request sent, awaiting response... 200 No headers, assuming HTTP/0.9
Length: unspecified
Saving to: ‘index.html’
index.html [ <=> ] 15 --.-KB/s in 0s
2024-08-02 17:35:14 (819 KB/s) - ‘index.html’ saved [15]
--2024-08-02 17:35:14-- http://80/
Resolving 80 (80)... 0.0.0.80
Connecting to 80 (80)|0.0.0.80|:80... ^C
$ cat index.html
hello from two
As you can see, all tests received valid responses from the server. The "start1" has |
Beta Was this translation helpful? Give feedback.
-
Hi,
I am trying to test the non blocking behavior of socket server. I took https://github.com/troublegum/micropyserver as my base, and then added concept from https://forum.micropython.org/viewtopic.php?f=16&t=4211 to make it non-blocking.
However, when the Poller is a local variable, it works beautifully, but if I make poller as a class variable, it does not work.
Here is my code. The class has 2 start methods, start1() and start2(). start1() uses a local variable to hold poll object, whereas start2() stores the poll object in the class member variable.
When I use start1() of the class, everything works fine. Both "Something Else" and "activity in my socket" shows up in th elog.
Here is the output, when I do 'curl 192.168.210.254' after the NB server starts.
However, when I comment start1() and use start2(), it becomes unreliable. The socket activity is detected sometimes. But when it stops detecting, it never detects ever again and I have to revert back to start1() to get it working.
Here is the output when it gets into that state. I did multiple 'curl 192.168.210.254' after the NB server starts, but it has no effect.
it is baffling me. What mistake I am doing here? Any idea why I am seeing this behavior?
Beta Was this translation helpful? Give feedback.
All reactions