WINC TCP socket accept not working, browsers show conn refusal

I am trying to run PetPy/ at master · IeiuniumLux/PetPy · GitHub just so I can see how a HTTP server is implemented

It doesn’t work, Chrome and Firefox both report that the connection is refused. Port used is 8088, I tried port 80 too (but the code definitely says port 8088). And I made sure it was http not https

My router’s client list shows a client “WINC-a5-3d” which is definitely correct, so I know the connection is good. Furthermore, ping to the IP assigned shows replies about 3ms.

Modifying the code to examine the args[0] of the OSError shows it is error -6, digging through the OpenMV github reveals this is “SOCK_ERR_INVALID_ARG” in /src/winc1500/include/socket/include/socket.h , most likely returned from “sint8 WINC1500_EXPORT(accept)(SOCKET sock, struct sockaddr *addr, uint8 *addrlen)” in /src/winc1500/src/socket.c . That function isn’t exactly an IO operation, so the acceptance is happening elsewhere. I am not familiar enough with the code to trace too far. It looks like something in function “static void m2m_ip_cb(uint8 u8OpCode, uint16 u16BufferSize,uint32 u32Address)” sets it after getting “u8OpCode == SOCKET_CMD_ACCEPT”.

Changing to soft-AP mode yields identical behaviour

I have tried changing the timeout from blocking to something short and it does not allow a connection to be accepted.

My firmware version: MicroPython v1.12-omv OpenMV v3.6.7 2020-07-20; OPENMV4P-STM32H743
WINC firmware is version: (19, 6, 1, 19, 3, 0, 1377184)

oh and UDP is definitely working, my other project implements a DNS server on port 53 and it’s responding to name resolution requests

Please help, thanks

Hi, I have a working RSTP server I can point you to. I can’t debug random user code.

It’s fairly robust.

Http just has different protocol headers that you have to return.

Note that I have on my to-do list to write an http server class for users. However, I’m getting the Arduino Interface library out the door right now.

Just take how TCP socket handling from me works and you should be good to go. You can print out what the remote client then sends and then craft your own http responses.

When I have time to write a server class I’ll do all this stuff for you and you will then just need to support the raw html.

Nope, the RTSP server example didn’t help. Running it in station mode works, VLC can connect to it. Running it in AP mode, I get the error:

VLC could not connect to "".
Your input can't be opened:
VLC is unable to open the MRL 'rtsp://'. Check the log for details.

I did get a HTTP server working borrowing the technique from the example, which is to not set a timeout at all, but use setblocking(True). That gets me a HTTP server working only in station mode. Switching to AP mode will still have the same problem (connection refusal seen on the client, and nothing seen on OpenMV) does not work (same symptoms), applying the setblocking(True) technique to it does not help either.

Do you need me to tap into those UART debug lines? The ones seen on top of the shield?

If you tell me how to blast an image out of the 40mb/s SPI bus, I could make a ESP8266 shield, I’ve gotten a project like this working on ESP before, just need a fat pipe for the images. EDIT: found it under pyb, maybe I’ll try this…

Hi, I’m almost done with our interface library. It lets you move data using the SPI bus at very high speeds.

I don’t know what’s wrong with AP mode. I don’t use that mode. Probably bugged. Can you post an re-producable error snippet to github as an issue and Ibrahim will fix it.

Access point is working fine, this is obvious but you need to connect to the access point first and then run the example, also I’m sure is not a valid address for clients, you should connect to

Yea I goofed there. I used wlan.ifconfig which gave me for everything. Turns out I should’ve been doing ipconfig from windows, default gateway is

I got the connection working. thanks

edit: actually, this all started when I implemented the DNS server for the soft AP, it fetched the IP from wlan.ifconfig since it was code ported from a ESP8266 and then resolved all the names to itself. On a ESP8266 this would’ve returned, but on WINC this is returning, which… lacking a bit in network knowledge, thought was valid.

What is the right API to retrieve the default gateway address? Hardcoding it seems… wrong