Code Monkey home page Code Monkey logo

Comments (16)

sandeepmistry avatar sandeepmistry commented on July 1, 2024

@drp0 what board(s) are you testing with?

On the MKR1000, using the SimpleWebServerWiFi.ino example sketch and using nc <IP address> 80 from a Mac. I can only establish 2 connections at a time, on the 2rd attempt Wireshark shows the connection being accepted, immediately followed by a disconnect.

from wifi101.

sandeepmistry avatar sandeepmistry commented on July 1, 2024

With the current ASF base, there is essentially a backlog of one pending connection until server.available() is called again. Any incoming connections will be accepted by the firmware, then immediately will be disconnected by the ASF code, see this block of code: https://github.com/arduino-libraries/WiFi101/blob/master/src/socket/source/socket_buffer.c#L216-L219

@ThibaultRichard any thoughts on how this can be improved?

from wifi101.

drp0 avatar drp0 commented on July 1, 2024

Hello Sandeep,

I am working with the Arduino mega 2560.

The wifi101 firmware is 19.4.4.

The library is version 0.8.0

Your experience on the Mac is like mine.

Could this use of a maximum of (up to) 2 sockets, also be the cause of the ftp download failure in #32?

The maximum number of tcp sockets in the library is more than two.

Cheers,

David

From: Sandeep Mistry [mailto:[email protected]]
Sent: 02 March 2016 20:58
To: arduino-libraries/WiFi101
Cc: drp0
Subject: Re: [WiFi101] Server uploads two images on a html page, the rest are not processed (#36)

@drp0 https://github.com/drp0 what board(s) are you testing with?

On the MKR1000, using the SimpleWebServerWiFi.ino https://github.com/arduino-libraries/WiFi101/blob/master/examples/SimpleWebServerWiFi/SimpleWebServerWiFi.ino example sketch and using nc 80 from a Mac. I can only establish 2 connections at a time, on the 2rd attempt Wireshark shows the connection being accepted, immediately followed by a disconnect.


Reply to this email directly or view it on GitHub #36 (comment) . https://github.com/notifications/beacon/ANHAGrOdyCNyVIq8hDDBsisFVBzndg5rks5ppfnQgaJpZM4Hi_CH.gif

from wifi101.

sandeepmistry avatar sandeepmistry commented on July 1, 2024

@drp0 thanks for the info. The behaviour in this issue is specifically related to TCP server sockets, so unrelated to #32.

from wifi101.

drp0 avatar drp0 commented on July 1, 2024

What is the socket limit on the Amtel chip?
I have a memory of reading somewhere in the arduino library that the maximum number of tcp sockets was 7, although I can-not recall which file contained the information.
I had a quick look at the code snippit [https://github.com/arduino-libraries/WiFi101/blob/master/src/socket/source/socket_buffer.c#L216-L219]
I am surprised it did not do a test of the number of sockets open, against the maximum number of sockets. Could this lead to a workround?

I have just tried commenting out line 218: close(pstrAccept->sock); in socket_buffer.c
The server will then upload all the images on a sample page of 4 pictures.
The arduino software issues a client.stop() correctly.
The library software does not appear to process the instruction and the client browser waits with a receiving data message. (I was not surprised)
If the browser cancel download "X" is selected, the server will supply the next request.
David

from wifi101.

sandeepmistry avatar sandeepmistry commented on July 1, 2024

What is the socket limit on the Amtel chip?

Correct it's 7, see socket.h.

I am surprised it did not do a test of the number of sockets open, against the maximum number of sockets. Could this lead to a workaround?

Agreed there should be a check.

Only work around I can think of is to have your sketch call server.avaible() more frequently for now.

from wifi101.

sandeepmistry avatar sandeepmistry commented on July 1, 2024

Hi @drp0, if you are still interested in this, could you please try PR #204 when you get a chance. Thanks.

from wifi101.

drp0 avatar drp0 commented on July 1, 2024

from wifi101.

sandeepmistry avatar sandeepmistry commented on July 1, 2024

Hi @drp0,

You can:

  1. Backup your <sketchbook>/libraries/WiFi101 folder
  2. Download https://github.com/sandeepmistry/WiFi101/archive/socket-buffer-winc1500.zip
  3. Extract zip
  4. Place zip from library in <sketchbook>/libraries/WiFi101
  5. Restart the IDE and try it out

To restore, delete the <sketchbook>/libraries/WiFi101 folder and replace with the one backed up in step 1).

from wifi101.

drp0 avatar drp0 commented on July 1, 2024

from wifi101.

sandeepmistry avatar sandeepmistry commented on July 1, 2024

Hi @drp0,

Thanks for trying and apologies for not being clear on what I wanted you to test.

  1.  I include  <TimeLib.h> as that worked in previous incarnations of yifi101
    

I seem to recall a lot of discussion on your choice of library for time support.

I get the warning “No system <time.h> header included, WiFi.getTime() wil always return 0”

So what have you changed and what are the implications for anything written in previous versions of >YIFI101?

No changes have been made for this.

  1.  The remote IP and port callback routine you gave me no longer works:
    

I've renamed socketBufferCb to socket_cb.

I hope you can maintain an option to get the remote IP for security reasons

It's easier to make have a public API for this once the PR is merged.

  1. I can now get 4 pictures back from yifi101 on one page- obviously a great improvement- further testing tomorrow

I have not yet tried to time the page serving rate- but it appears to be faster.

Ok, that's great news. The changes in the pull request allow the WiFi101 to have more than one accepted socket pending from a server. Previously as the issue is titled after one pending accepted connection, the WiFi101 library would close the socket.

from wifi101.

drp0 avatar drp0 commented on July 1, 2024

Hi Sandeep,
Good news indeed.
If the socket limit is 7, what would happen if a page contained more than 7 servable objects?

I tried altering line 10 above to
socket_cb(sock, u8Msg, pvMsg);
and got
socket_cb was not declared in this scope
Is there a temporary work round?

David

from wifi101.

sandeepmistry avatar sandeepmistry commented on July 1, 2024

If the socket limit is 7, what would happen if a page contained more than 7 servable objects?

So one socket will be taken up by WiFiServer, so that leaves 6 left for incoming connections. You'll have to carefully manage WiFiClient's and check if there is pending socket data if you are using an AVR based board.

Is there a temporary work round?

In src/WiFi.cpp there the following line:

static void socket_cb(SOCKET sock, uint8 u8Msg, void *pvMsg)

remove the static so it becomes:

void socket_cb(SOCKET sock, uint8 u8Msg, void *pvMsg)

then in your sketch add void socket_cb(SOCKET sock, uint8 u8Msg, void *pvMsg); to forward declare it.

from wifi101.

drp0 avatar drp0 commented on July 1, 2024

That all works
So far the server appears more stable than before.
Thanks,
David

from wifi101.

sandeepmistry avatar sandeepmistry commented on July 1, 2024

Great, thanks for testing and the feedback :)

from wifi101.

sandeepmistry avatar sandeepmistry commented on July 1, 2024

Now that PR #204 is merged, this is fixed.

from wifi101.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.