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)
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.
var gun = Gun('https://gun.rildev.tk/gun');
says "fails to connect" so something still wrong about how its exposeduser.auth(alias, passphrase, callback, { change: 'new-pass-value' })
https://gun.eco/docs/FAQ
server {
server_name gun.rildev.tk;
location / {
proxy_pass https://localhost:8765;
}
location /gun {
proxy_pass https://localhost:8765;
# websocket configuration
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
}
# Certbot automatic configuration
}
@connor-davis According to this https://gun.eco/docs/User#user-auth
user.auth(alias, pass, cb, opt)
or also
user.auth(pair, cb, opt)