Web app < - > client communication

  1. ‹ Older
  2. 2 years ago

    This forum is buzzing with great info. & ideas.
    Much appreciated.

    I have experience with MySQL, MS local dB & server & SQLite.

    However, please note this will (hopefully) be a commercial system & I really don't like the idea of customer having to install & configure a server database.
    Minimal configuration is preferred, but I understand the benefits of a server dB.

    I would prefer a local dB, so it'll be up to the web app to drive this.
    Having said that, i have no experience with PostgreSql. Is this easy to install & deploy? (I assume it is a server dB)

  3. I've previously had handlespecialurl working with a single client connection.

    However, i didn't get around to investigating the performance & reliability of handlespecialurl in a realistic environment.

    For example; how are multiple, possibly simultaneous requests being sent by clients handled by the web app handlespecialurl?
    I don't understand the workings of this method.
    Are all requests qued until accepted? With timeouts?
    Is this a race condition... who gets there first gets served?
    Do some requests get lost?

  4. Going back to a polling method:

    Handlespecialurl is effectively just listening & not polling.

    How can you send a request from web app? I.e. poll the clients rather just listen.

    Thanks

  5. Edited 2 years ago

    You can use EasyTCPSocket for the polling. I made a similar program that polls modbus data from different remote locations. I used ConsoleApps to perform all the requests and receive the responses using EasyTCPSocket. Then my WebApps sessions connect to the ConsoleApps via EasyTCPSocket (only the ones that the session requires) to display the live data.

  6. Hi Derek,

    Did you write your own, true modbus tcp master/slave functions or did you pass modbus rtu over tcp?

  7. I did not design the sensors if thats what you mean. I am sending my commands using standard modbus function codes and either reading or writing to registers that are on the sensors and devices that i'm controlling and monitoring. For each modbus network I am using a separate console app that is I automatically spawned after a new job is set up and the types of sensors that are being used are set. Each site can be adjusted on the fly of coarse using the TCPconnection between the WebApp and console app. For my device side im using a LTE radio that has a serial port and is passing the data through a serial - rs485 converter. We are running these on remote locations that won't typically have there own network, middle of ranches and what not. These are oil field locations.

  8. Rudolph T

    10 Jul 2018 Xojo Pro South Africa
    Edited 2 years ago

    I Would prefer using an MQTT server like Mosquitto (simpler) or RabbitMQ. Then use the XOJO MQTT library developed by Zaatar Digital to create a client that listens to all the sensors on various topics. You can have XOJO clients running as Console Apps, Web Apps or Desktop Apps.

    A While back I made a PHP script and a XOJO Console App that ran as service listening on a topic on the MQTT server and logged all the data to MySQL. I Then used a XOJO Webapp to display the data to the end user.

    *** Unfortunately I'm not at liberty to share the code for my projects but I can confirm that the Github project for XOJO MQTT works well. We where able to use it in a number of ways.

    https://github.com/zaatardigital/mqttlib-demo

  9. Oliver O

    10 Jul 2018 Testers, Xojo Pro https://udemy.seminar.pro

    I think that with Xojo you can do this quite easily (imho).
    Collect data with desktops and send data to webapp. Webapp can present data in tables or graphs and can serve webpages to any authorized user in the lan....

    This sample here should still work:
    http://osswald.com/koblenz16/myservice.zip

    ... I am on vacation, cannot test myself right now :)

  10. Dereck - you said you are using Xojo EasyTcpsocket for your modbus transport.
    The reason i queried this is because it sounds like you are transferring modbus rtu packets over tcp, which, as odd as it sounds - isn't proper modbus TCP, it's modbus rtu over tcp - there's a difference!

    Rudolph - your post has prompted me to read up a little on mqtt this evening. Looks interesting & specifically for IoT but somewhat intimidating to implement.
    Not sure if this is right for me.
    Is it fairly straightforward to implement? Costs involved?

    Oliver - easily said, & it's been suggested that "handlespecialurl" be used in the web app to receive the data... but... I'm not sure how this works when there could be 10's if not hundreds of clients sending data (~100 bytes) to web app at same time. How will handlespecialurl cope this this amount of data?

  11. Oh, and Oliver - how dare you be on vacation! Get home at once to try the code! lol ;-)

  12. Rudolph,

    The more i read about mqtt the more attractive it seems.

    I shall try to get a system working at my workplace over the next few days.
    I'm hoping that i can install & run mosquito broker on my Win 7 desktop machine & take it from there.
    Sounds like a bit of a fuss to install, however.

    Thanks for the interesting lead!

  13. Rudolph T

    10 Jul 2018 Xojo Pro South Africa

    @Darren L Rudolph,

    The more i read about mqtt the more attractive it seems.

    I shall try to get a system working at my workplace over the next few days.
    I'm hoping that i can install & run mosquito broker on my Win 7 desktop machine & take it from there.
    Sounds like a bit of a fuss to install, however.

    Thanks for the interesting lead!

    The whole puzzle might look intimidating but it becomes really straightforward. I Worked with it on Linux, Win 7, Win 10 and Win Server 2012R2. So I know it works and is very stable. But as a test you can just use one of the public servers if you get stuck. Just keep it mind that anybody can read your topics on a public server. https://test.mosquitto.org/ .

    RabbitMQ also works well but it intimidated me in the beginning :-). Both EMQ and RabbitMQ gave me hassle a month into my experiment by crashing frequently while Mosquitto just never crashed.

    ps. @Eric d Rochette the guy that started the Github library for XOJO wants use the code not only to create a clients but also wanted to make a XOJO crafted MQTT server.

  14. Oliver O

    11 Jul 2018 Testers, Xojo Pro https://udemy.seminar.pro

    @Darren L <..>
    Oliver - easily said, & it's been suggested that "handlespecialurl" be used in the web app to receive the data... but... I'm not sure how this works when there could be 10's if not hundreds of clients sending data (~100 bytes) to web app at same time. How will handlespecialurl cope this this amount of data?

    http://docs.xojo.com/index.php/WebApplication.HandleSpecialURL

    Because this is an application-level URL, the event is handled without a session context. Unhandled exceptions will be handled by WebApplication.UnhandledException. If you return False from WebApplication.UnhandledException this event will output Internal Server Error html. This will not cause your app to terminate.
    Calls to this event are threaded so that simultaneous calls from clients can be handled properly.
    In CGI mode, the headers sent with the WebRequest object have the same limitations as they do in WebSession.Header.
    Session is not available from this event handler.

    First of all I would create the webservice as a Xojo standalone webapp (not as a cgi).

    For instance, I run several siblings of a webapp on one linux server behind a haproxy loadbalancer. This setup can handle high loads.

    In your case you first must make sure that the pc which is running the webapp is powerful enough(ssd and memory) and then it most likely can handle the amount of requests you mentioned.

    It also depends on the work which the webapp has to execute. If this is a time-consuming process, then you may want to hand over all incoming information to a method running in a thread and quickly return true from handleSpecialURL.

    In short, whether it will work for you depends on how you design your webapp as well.

  15. Thanks, Oliver.

    So HandleSpecialUrl is "threaded", but how does this work, exactly?
    How does this guarantee to handle every request coming in at once? (e.g 1000 requests coming in at exactly the same time... what happens?)

    Sorry, I don't understand what a "haproxy loadbalancer" is - could you explain what this is, please?

    In general, I'd really appreciate a clear, layman's explanation of what happens when multiple requests are made. Perhaps even a diagram? :-)

  16. Rudolph,

    I managed to install mosquito at work today and used the provided _sub and _pub consoles to send/receive messages.

    Looks good so far.

    I note that there are also .NET Mqtt libraries which I will also have a play with.

    Again - thanks.

  17. Rudolph,

    I have an Mqtt systrm running at work.

    Fantastic. Love it. I can see a lot of potential.

    Doesn't seem to be THAT popular though. Perhaps becsuse it's relatively new to the greater public?

    Thanks again for the lead, it's a very interesting protocol.

  18. José M

    13 Jul 2018 Testers, Xojo Pro Spain

    MQTT Is very popular in the MCU's world, like Arduino, ESPxx, MSP, Home Automation, etc... It's more that world than "high level" computing :-)

  19. last week

    I work for a small company that makes educational robots for grade schools. Since kids will likely not be in the classroom this fall, I would like to try and make an app to control the robot over the internet using Mqtt. I found this thread and tried to run the demo project from: https://github.com/zaatardigital/mqttlib-demo
    I am using Xojo 2019 3.1
    I got two errors, both in Mqttlib.tcpsocketadapter.constructor, line 7
    Type mismatch error. Expected delegate Delegate(TCPSocket, RuntimeException), but got delegate Delegate(TCPSocket) AddHandler inTCPSocket.Error, WeakAddressOf handleTCPSocketError.

    This method requires fewer parameters than were passed. AddHandler inTCPSocket.Error, WeakAddressOf handleTCPSocketError.

    Can anyone help me?
    This stuff looks waaaayy over my head :)

  20. Wayne G

    Jun 26 Testers, Xojo Pro, MVP Auckland, New Zealand

    In the method definition for HandleTCPSocketError add the parameter err As RuntimeException. The definition should read "HandleTCPSocketError(inTCPSocket As TCPSocket, err As RuntimeException)". This makes the Event Definition API 2.0 compatible, but the code can remain API 1.0.

  21. 4 days ago

    Thank you so much. This forum rarely lets me down!

or Sign Up to reply!