Git Product home page Git Product logo

Comments (23)

Sampozzo avatar Sampozzo commented on June 19, 2024 1

I think that they must provide some working example, instead of asking to study the Basic programming concepts.

from arduinowebsockets.

kevin-guzman avatar kevin-guzman commented on June 19, 2024

Can you solve the problem? I have the same issue.

from arduinowebsockets.

jaydip-pawar avatar jaydip-pawar commented on June 19, 2024

Can you solve the problem? I have the same issue.

No, but For now I am handling it from App side, like when I send message then I am disconnecting client from App and then again connecting it to send another message.

from arduinowebsockets.

gilmaimon avatar gilmaimon commented on June 19, 2024

Hi, I didn't really get the scenario here..

You want to have a server that accepts a client and reads multiple messages? Because your code only reads one message and then closes the connection... Please try to better explain the use case and the bug (if you think this is a bug).

from arduinowebsockets.

jaydip-pawar avatar jaydip-pawar commented on June 19, 2024

Hi, I didn't really get the scenario here..

You want to have a server that accepts a client and reads multiple messages? Because your code only reads one message and then closes the connection... Please try to better explain the use case and the bug (if you think this is a bug).

Yes, I want a server that accepts multiple messages until client is connected, But now When client connects to the server and sends a message after that if same client send another message it not listen by server, That's all I want is a server that accepts multiple messages.

from arduinowebsockets.

gilmaimon avatar gilmaimon commented on June 19, 2024

Hi, I didn't really get the scenario here..
You want to have a server that accepts a client and reads multiple messages? Because your code only reads one message and then closes the connection... Please try to better explain the use case and the bug (if you think this is a bug).

Yes, I want a server that accepts multiple messages until client is connected, But now When client connects to the server and sends a message after that if same client send another message it not listen by server, That's all I want is a server that accepts multiple messages.

Sorry for being rude, but you have to know programming for working with this library... You probably don't expect me to write your code for you? You have most of the API documented in the Wiki and multiple simple and more complex examples as well as a README with examples from which you can understand the basics of how to work with clients and such... In the Wiki there is even an advanced example of working with multiple clients simultaneously.

Meanwhile I will label the issue accordingly, maybe someone with some free time will write you an example specific to your case...

Gil.

from arduinowebsockets.

jaydip-pawar avatar jaydip-pawar commented on June 19, 2024

Hi, I didn't really get the scenario here..
You want to have a server that accepts a client and reads multiple messages? Because your code only reads one message and then closes the connection... Please try to better explain the use case and the bug (if you think this is a bug).

Yes, I want a server that accepts multiple messages until client is connected, But now When client connects to the server and sends a message after that if same client send another message it not listen by server, That's all I want is a server that accepts multiple messages.

Sorry for being rude, but you have to know programming for working with this library... You probably don't expect me to write your code for you? You have most of the API documented in the Wiki and multiple simple and more complex examples as well as a README with examples from which you can understand the basics of how to work with clients and such... In the Wiki there is even an advanced example of working with multiple clients simultaneously.

Meanwhile I will label the issue accordingly, maybe someone with some free time will write you an example specific to your case...

Gil.

I'm not saying to write any code for me, but I think you have not understood my question. I have checked wiki and your examples as well, but I am not saying to work with multiple clients, as your example your code listen to message and when it receives the message it close the connection and again steps repeat like another client connect and send the message, I have only one client but my client is not able to send multiple message that's what I am saying. In my code, client is connecting with server just one time, but If I refer your code, Then I need to connect my client again and again to server for sending multiple messages. My question is simple that I have to receive multiple messages from same client without repeating the client-server connection process. If you understand my question then just tell me what I am missing. Thank you

from arduinowebsockets.

adelin-mcbsoft avatar adelin-mcbsoft commented on June 19, 2024

@jaydip-pawar , you're calling client.close(); in the body of the loop(), it's pretty obvious that at your next iteration you won't receive any else message as you close the connection...
Remove that line and you'll be able to receive as many messages as you'd like, as long as the client is still connected.
Call the .close() method only when it's appropriate.

@gilmaimon was right, you need to understand these basic aspects before raising any issue, it's about the code logic here, not the library itself. What you have there is an example, you have to adapt it based on your own needs :)
Good luck.

from arduinowebsockets.

jaydip-pawar avatar jaydip-pawar commented on June 19, 2024

@jaydip-pawar , you're calling client.close(); in the body of the loop(), it's pretty obvious that at your next iteration you won't receive any else message as you close the connection... Remove that line and you'll be able to receive as many messages as you'd like, as long as the client is still connected. Call the .close() method only when it's appropriate.

@gilmaimon was right, you need to understand these basic aspects before raising any issue, it's about the code logic here, not the library itself. What you have there is an example, you have to adapt it based on your own needs :) Good luck.

Sorry, I thought I mentioned it in first question, But I tried with removing client.close() but still It's not working, That's why I asked.

from arduinowebsockets.

Sampozzo avatar Sampozzo commented on June 19, 2024

The same here.
Using the server example here: https://github.com/gilmaimon/ArduinoWebsockets/blob/master/examples/Esp32-Server/Esp32-Server.ino and removing the client.close(); at the end do not solve the problem.

You can connect to the server, but when you send the first message, the server reply and then close the connection.

from arduinowebsockets.

Sampozzo avatar Sampozzo commented on June 19, 2024

@jaydip-pawar have you solved the issue?

from arduinowebsockets.

jaydip-pawar avatar jaydip-pawar commented on June 19, 2024

Not yet, I also tried other libraries for it but in my case I face many bugs so I tried with Bluetooth for transferring data and it's work fine with my code, So if you just want to transfer the data then try bluetooth instead of WiFi.

from arduinowebsockets.

gilmaimon avatar gilmaimon commented on June 19, 2024

I think that they must provide some working example, instead of asking to study the Basic programming concepts.

Who are these "they" you mentioned 🤔

Your question has been answered, if you don't like the examples you can use another library, that will surely fix your problems.

from arduinowebsockets.

Sampozzo avatar Sampozzo commented on June 19, 2024

Where it was answered?

from arduinowebsockets.

Sampozzo avatar Sampozzo commented on June 19, 2024

Can you simply explain why the server close the connection even if you remove the client.close() line?

from arduinowebsockets.

jaydip-pawar avatar jaydip-pawar commented on June 19, 2024

I think that they must provide some working example, instead of asking to study the Basic programming concepts.

Who are these "they" you mentioned 🤔

Your question has been answered, if you don't like the examples you can use another library, that will surely fix your problems.

Sorry for being rude but without answering to the answer and just closing the issue just because some arrogance is not good, rather than just arguing just answer it, simple! We use libraries doesn't mean we haven't any idea about programming just to save time we use it, but if someone ask questions or queries, rather than arguing give answer to them and improve your library by fixing any issue if there.

from arduinowebsockets.

gilmaimon avatar gilmaimon commented on June 19, 2024

Obviously the client instance is going out of scope so you can't interact with it anymore, so why would the connection stay open? The destructor is called and the connection is closed. If you want to keep interacting with the client you must keep interacting with the client object. If you let it go out of scope the connection will be closed (like any other RAII class).

from arduinowebsockets.

gilmaimon avatar gilmaimon commented on June 19, 2024

I think that they must provide some working example, instead of asking to study the Basic programming concepts.

Who are these "they" you mentioned 🤔
Your question has been answered, if you don't like the examples you can use another library, that will surely fix your problems.

Sorry for being rude but without answering to the answer and just closing the issue just because some arrogance is not good...

"Apology" not accepted...

from arduinowebsockets.

jaydip-pawar avatar jaydip-pawar commented on June 19, 2024

Obviously the client instance is going out of scope so you can't interact with it anymore, so why would the connection stay open? The destructor is called and the connection is closed. If you want to keep interacting with the client you must keep interacting with the client object. If you let it go out of scope the connection will be closed (like any other RAII class).

Right! But if object is declared globally and destructor is not called then why it's not interacting with client? Just after completing one loop client is disconnecting without calling client.close()

from arduinowebsockets.

gilmaimon avatar gilmaimon commented on June 19, 2024

Obviously the client instance is going out of scope so you can't interact with it anymore, so why would the connection stay open? The destructor is called and the connection is closed. If you want to keep interacting with the client you must keep interacting with the client object. If you let it go out of scope the connection will be closed (like any other RAII class).

Right! But if object is declared globally and destructor is not called then why it's not interacting with client? Just after completing one loop client is disconnecting without calling client.close()

That's the point, it's not declared globally. It's declared inside the function loop. And when the function finishes, the client is destructed (and thus, closed)

from arduinowebsockets.

jaydip-pawar avatar jaydip-pawar commented on June 19, 2024

Obviously the client instance is going out of scope so you can't interact with it anymore, so why would the connection stay open? The destructor is called and the connection is closed. If you want to keep interacting with the client you must keep interacting with the client object. If you let it go out of scope the connection will be closed (like any other RAII class).

Right! But if object is declared globally and destructor is not called then why it's not interacting with client? Just after completing one loop client is disconnecting without calling client.close()

That's the point, it's not declared globally. It's declared inside the function loop. And when the function finishes, the client is destructed (and thus, closed)

But I have tried it by declaring globally and it won't work, why?

from arduinowebsockets.

gilmaimon avatar gilmaimon commented on June 19, 2024

Without seeing the code I have no idea, but I assume you kept the loop code exactly as is so your client keep getting re-initialized (so the client keeps getting closed)

These questions are symptoms of lacking experience in cpp and programming in general, which is why I think you should focus on those subjects before doing embedded and networking. You can be offended by this if you want, it's not arrogance. Even if I'll help you with your code line by line, you would still encounter other issues down the road, that has nothing to do with the library. I see that I already said that 2 months ago, if you would have invested the time in it, you could answer all of your questions yourself.

from arduinowebsockets.

jaydip-pawar avatar jaydip-pawar commented on June 19, 2024

Without seeing the code I have no idea, but I assume you kept the loop code exactly as is so your client keep getting re-initialized (so the client keeps getting closed)

These questions are symptoms of lacking experience in cpp and programming in general, which is why I think you should focus on those subjects before doing embedded and networking. You can be offended by this if you want, it's not arrogance. Even if I'll help you with your code line by line, you would still encounter other issues down the road, that has nothing to do with the library. I see that I already said that 2 months ago, if you would have invested the time in it, you could answer all of your questions yourself.

Sorry but i don't think adding auto client = server.accept(); in setup re-initialise object with every loop iteration, and I would have been happy, If you had told me this earlier, I would have shown you my code and we would have reached to the conclusion. But no problem I have that much knowledge to find solutions and I found better solution over it, later but ok thanks for your valuable answers, it wouldn't help me but if someone encounter this issue It would be great if he could get his solution as you said if I'm wrong.

from arduinowebsockets.

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.