amark on master
ok ack + webrtc Merge branch 'master' of http:/… bump (ok ack + webrtc) @Draeder… (compare)
amark on master
websocket ../index to ./index (… (compare)
amark on master
PANIC tests + AXE get dedup + f… Merge branch 'master' of http:/… (compare)
amark on master
lib/ison: Use setTimeout instea… (compare)
@amark I am building a GPS application using Electron vue. My server side setup (node server, using as a backup storage server) is working fine. However my client side (Electron) is not able to sync data. It is able to push data though. When I push data it syncs the data to the server (I can log this on the node.js server) and keeps a local copy in Electron. This is working fine. Now if I delete local cache (electron developer tools), it is unable to fetch the latest data from the server (which it itself pushed). I put data using the following:
let newUsername = 'myNewUser'
const userObj = {};
userObj[newUsername] = {
username: newUsername,
};
this.gun.get("users").put(userObj, () => {
});
I have connected to the server using peers:gun: GUN({ peers: ["https://example.com/gun"], axe: false }),
According to the discussion here: amark/gun#823 , I have axe: false
on all clients (node.js and electron client)
This returns undefined
in Electron console:
this.gun.get("users").map().on((node) => {
console.log(node)
})
I ran a local node server on my PC and also ran a vue client (instead of Electron). What I noticed is that, doesn't matter what you use: .on
or .once
, data comes in only after changes are made to the server instance. I thought .once
would give me existing data?
When my local node and vue client was running, I put existing data again to the remote server instance, the new data shows up instantly on both local node and vue client.
How do I get the latest data that is already existing in the server, without putting new data?
<head>
<link href="https://cdnjs.cloudflare.com/ajax/libs/tailwindcss/2.2.17/tailwind.min.css" rel="stylesheet">
</head>
<div class="app h-screen bg-gray-100" x-data="{messages: []}" x-init="
$watch('messages', value => window.scrollTo({top: document.body.scrollHeight, behavior: 'smooth'}))
gun = Gun('https://178.62.11.88:8765/gun');
chat = gun.get(`chat/${location.hash.slice(1)}`);
chat.get('messages').map().once((message) => {
messages = messages ? [...messages, message] : [];
});
">
<div class="messages divide-y divide-gray-300 pb-11">
<template x-for="message in messages">
<div class="message px-4 py-2 break-all" x-text="message"><span class="font-bold">user:</span> message</div>
</template>
</div>
<div class="chat-bar fixed bottom-0 w-full flex"><input class="rounded-none border w-full px-4 py-2 bg-white" type="text" placeholder="Enter your message here..." x-ref="unsentMessage" @keyup.enter="sendMessage"><button class="send bg-blue-500 text-white px-4 py-2 uppercase text-sm font-bold tracking-widest" @click="sendMessage">send</button></div>
</div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/gun/0.2020.1235/gun.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/alpinejs/3.4.2/cdn.js"></script>
<script>
function sendMessage() {
if (this.$refs.unsentMessage.value) {
chat.get('messages').set(this.$refs.unsentMessage.value);
}
this.$refs.unsentMessage.value = '';
}
</script>
pm2
session cd node_modules/gun && HTTPS_KEY=/home/rildev/ssl/rildev/privkey.pem HTTPS_CERT=/home/rildev/ssl/rildev/fullchain.pem npm start
axe: false
(maybe try that on both?) I was hoping that was causing the issue. :clap: @connor-davis . So its not an issue with GUN in electron, as the vue one also does not get the first value? Question, if you switch your .once(
to a .on(
does it fire initially? To debug if .once(
is being buggy.@amark same issue with both .on
and .once
. The only difference is that with .on
, it does not go into the callback so there is no log.
I have also set axe: false
on all clients. The weird thing is as soon as new data is pushed to the server, it syncs with all connected clients, so the connections look fine. It is unable to get already existing data.
@amark My server setup looks like this:
import Gun from 'gun';
import "gun/nts";
import "gun/lib/radix";
import "gun/lib/radisk";
import "gun/lib/store";
import "gun/lib/rindexed";
const PORT = 8080;
const HOST = "0.0.0.0";
var http = require('http');
var server = http.createServer();
var gun = Gun({ web: server, axe: false });
server.listen(PORT, HOST, () => {
console.log(`Server listening to localhost:${PORT}/gun`);
});
I checked the radata folder and it does contain old data
@amark I fixed the SSL Certificate issue with an Nginx proxy looking like this
server {
server_name gun.rildev.tk;
location / {
proxy_pass https://localhost:8765;
}
# Certbot auto-generated config
}
So now gun.rildev.tk/gun should be usable right?
But when I connect to rildev.tk/chat/#gun-chat, it still doesn't sync like before.
Is there something else I'm missing here?
https
instead of http
in the proxy_pass
matters.