Does WebSocket work for Mobile App?

Hi everybody,
Does WebSocket work for Mobile App?
My web app provides instant refresh using Wappler WebSocket (sockets=“true” + refresh steps):

<dmx-serverconnect id="scListeMembres" url="/api/equipe/liste_membres" dmx-param:idequipeencours="idEquipeEnCours.value" sockets="true"></dmx-serverconnect>

The mobile app (Framework7, Capacitor) SC are hosted on the web app and calls the same DB (Nodes, BS5, Postgresql).
Can I use the same sockets=“true” process for my Mobile App?
If not, how to deal with real time data update?

Many thanks
Sylvain

Yes you can fully use websockets in mobile apps. Just make sure you specify your remote URL where you Wappler Project API is running:

image

1 Like

Trop bien!

Thanks for your answer George!

Few questions:

  1. Should I add a Socket component on every pages (that own SC API)? Only the index page?

  2. I understand I need only one socket component per page, not per SC, correct ?

  3. I see you added the component just before the View:“main” - is there a specific “place” to add the component?

Well any main page needs one. Usually your mobile is a SPA page, so then you need it only on the main page indeed.

Yes, just one per page.

Well it doesn’t really matter but usually you put it somewhere on top.

1 Like

thanks for precisions!

Last question:
This doesn’t work with Browser? Only with emulators?

I added sockets="true" to my SC and socket component and no refresh.

Hi George,
(Mobile app / emulator / Capacitor + bootstrap5)

Setting an url in the field do not set the url in the meta… ie the sockets is not well setted… and refresh does not work.
As soon as I add sockets="true" in the meta dmx-serverconnect the result is not displayed anymore in my app.

<dmx-socket id="socket1"></dmx-socket>

<dmx-serverconnect id="scGetMaintenance" url="https://v2.giloo.me/api/admin/mode_maintenance/maintenance" credentials="true" sockets="true"></dmx-serverconnect>


<script is="dmx-flow" id="flow_check_maintenance" type="text/dmx-flow" autorun="true">{
  condition: {
    if: "{{scGetMaintenance.data.queryGetModeMaintenance.actif==true}}",
    then: {
      steps: {
        run: {
          action: "{{browser_main.goto('/index.html#!/maintenance',true)}}",
          output: true,
          outputType: "text"
        }
      }
    },
    outputType: "boolean"
  }
}</script>

<p>maintenance :{{scGetMaintenance.data.queryGetModeMaintenance.actif}}</p>

Thanks for your help.
I need to refresh not only this maintenance SC but every SC from my app.

Sylvain

What version of Wappler are you on? Websockets stopped working completely in 5.8 (released two weeks ago) so if you’re on a recent version, that may be your issue. Per the updates here Debugging Issues with Websockets we’re expecting various fixes in the next release.

Thanks for the update > I use Wappler 5.7.0

Which version of App Connect do you use on your page? Just open the file dmxAppConnect.js and check the version number in the header comment.

/*!
App Connect
Version: 1.14.12
© 2023 Wappler.io
@build 2023-03-14 12:22:18
*/

It looks like it’s working fine since 5.8.2 + sockets.js file update.
Thanks

Hey @sylvainbaron did you have to replace sockets.js in your mobile app project?

Hi Dorian,
5.8.2 comes with an extension update since yesterday so you shouldn’t need to replace, it 'll be done automatically i guess.
Don’t forget to add <dmx-socket id="socket1" remoteurl="http://your-domain.com"></dmx-socket> in your index page for mobile.

Thanks a lot! But I probably have a bud in mine. I can’t successfully save remote url.
The value set is not retained for some reason. Did that happen to you?

This happened to me previously, using Wappler 5.7.0 - It was impossible to save the remoteurl param?
Since 5.8.2 I don’t have the problem anymore :slight_smile:

I see. Thanks again.
Do you have the Beta or Stable version?

Stable :wink:

I have the same! Strange.