[Native Websocket Plugin] Is it possible to use websockets with the app 100% offline?
Mobile icon
Forge component by Upresh Tikam
Application Type

Hello, I hope you are well, can anyone tell me if it is possible to use websockets with the app offline?

I'm developing an OS app for Android, and I was wondering if it's possible to use websockets when the app is 100% offline. (no connection).


The WebSocket protocol is fundamentally reliant on a live connection between the client and server to facilitate real-time data exchange. In an offline scenario where there's no internet connection, WebSockets wouldn't function as they require an active network connection.

However, you do have a couple of alternatives:

Local Storage: If the app is offline, you could use local storage to store data temporarily and sync it once the device goes online.

Service Workers: While not the same as a WebSocket, service workers can help to manage some offline functionality and cache assets and data.

Background Jobs: If your app has critical functionality that must run even when offline, consider implementing background jobs that can run native code when triggered.

Fallback Polling Mechanism: You can design your app to fall back on a less real-time, more traditional request-response model when WebSockets are not available.

Given that you mentioned you're developing for Android and the component you're looking at uses OkHttp, this library does provide some offline capabilities, but it's worth noting that these are not designed for real-time interactions in the same way that WebSockets are.

I hope this answers your query. Feel free to reach out if you have any more questions!

RAD Manage

Hi Rad, thanks for the replies.

I'm thinking the following scenario, in which case the application and websockets library would be in the same environment.

Example: A local server (standalone) where websockets is configured and an android emulator in that environment, so both would be offline from the internet, but would be on the local network.

At certain times, this server will connect to the internet just to sync the information.

From what I understand in your answer, this component was not designed to work 100% off the internet, and that it only has some functionality that runs offline.

Again, thanks for the guidance.

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.