ssbc / ssb-client Goto Github PK
View Code? Open in Web Editor NEWclient library to scuttlebot
client library to scuttlebot
I have an app connecting on my local computer which will do some work on sbot, then idle until the user does something. After 30s, the websocket connection closes.
I checked the logs, and it doesn't look like the close is initiated by sbot or the app. I think this is a choice by the browser (or possibly server code) to disconnect. TCP keepalive isn't used in Websockets, you have to send ping/pong messages to keep it active.
The app could listen for closes and reconnect. This line before any activity also works:
if (client.closed)
client.reconnect().auth(SSBKeys.createAuth(user.keys))
But I don't like having to do that in every application. It also closes any live streams, so they have to be re-initialized.
This does work as a keepalive:
setInterval(function () {
console.log('ping')
ssb.whoami()
}, 15e3)
Do we want to consider a ping
method in the ssb api? What's the best way to deal with this?
Problem: I just want to change my remote
, but SSB-Client requires that I specify my keys, caps, manifest, etc., because these fields are mandatory in the custom client.
Solution: Let's just use the defaults unless they're specified?
I'm thinking that maybe we shouldn't mix crypto code with networking code.
If you pass you keys to it it needs to be audited, we want to minimize that. maybe it's better to make this just be about getting an rpc connection and then having another part to manage creating the messages.
Also, I noticed that this publish
implementation will not work if you call it in parallel,
but the implementation in https://github.com/ssbc/secure-scuttlebutt/blob/master/feed.js
does queue it so you can call feed.add
as many times as you like.
rate the current state of the documentation out of 10.
is it clear what this is used for? is anything confusing or weird?
is there api documentation?
read code, do you see any undocumented methods?
for a method is there any undocumented options?
If you make changes, give a new rating.
7.5. I'm going to run through Mix's tutorial for basic client and see if I can understand more of what's going on. :)
I've started getting this error in minbase since upgrading to [email protected]
. It seems to track back to the blobs logic in ssb-client
. Downgrading to the previous version appears to solve the issue.
The error:
cb is not a function
TypeError: cb is not a function`
at file:///home/ev/minbase/build/index.html:14211:11
at file:///home/ev/minbase/build/index.html:9766:14
at file:///home/ev/minbase/build/index.html:9715:14
at file:///home/ev/minbase/build/index.html:9707:5
at file:///home/ev/minbase/build/index.html:9756:17
at file:///home/ev/minbase/build/index.html:11229:24
at file:///home/ev/minbase/build/index.html:11451:7
at next (file:///home/ev/minbase/build/index.html:11225:11)
at sink (file:///home/ev/minbase/build/index.html:11246:9)
at sink (file:///home/ev/minbase/build/index.html:9758:7)
Which leads to the cb(err, actualHash)
in blobs.js
Not sure how to fix? cc @regular
Fails while attemping to install. Any help is appreciated!
NPM version 6.4.1
Node version 10.15.3
{Project Directory}\node_modules\secret-handshake\node_modules\sodium-native\d
eps\libsodium>del tmp tmp2 tmp3
events.js:174
throw er; // Unhandled 'error' event
^
Error: spawn C:\Program Files (x86)\MSBuild\14.0\Bin\MSBuild.exe ENOENT
at Process.ChildProcess._handle.onexit (internal/child_process.js:240:19)
at onErrorNT (internal/child_process.js:415:16)
at process._tickCallback (internal/process/next_tick.js:63:19)
Emitted 'error' event at:
at Process.ChildProcess._handle.onexit (internal/child_process.js:246:12)
at onErrorNT (internal/child_process.js:415:16)
at process._tickCallback (internal/process/next_tick.js:63:19)
npm WARN [email protected] No description
npm WARN [email protected] No repository field.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] install: `node-gyp-build "node preinstall.js" "node postinstall.js"`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
this commit ce09df1
probably shouldn't have been a patch level change @dominictarr
It fundamentally changes the expectations of ssb-client options:
1KHLiKZvAvjbY1ziZEHMXawbCEIM6qwjCDm3VYRan/s=
config.caps.shs
Hi,
When using sbot.private.publish(etc), with sbot being ssbClient(function (err, sbot) {blabla}) I get this error:
(node:41004) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): TypeError: Cannot read property 'publish' of undefined
(node:41004) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
And when loging sbot.private, I get undefined, and when loging sbot object I don't find the private function.
Am I missing something?
Thanks in advance
When passing the result of sbot getAddress
to ssbClient, it results in net.connect is not a function
sbot server
by default binds to global ip address to listen
ssbClient
by default connects to localhost
this makes it difficult to automatically start a server and use it.
I've always been a bit confused at why this module checks ~/.ssb/manifest.json
instead of calling manifest()
over muxrpc and returning the results. Is this something that we can safely change, or is there a reason for the manifest to be cached in the filesystem?
Unable to resolve module path
from /Users/mtahir/Desktop/scuttlebut/node_modules/ssb-client/index.js
: Module path
does not exist in the Haste module map
It would be useful for ssb-client to have something you can look at to see if it's actually connected, or a mechanism to auto-reconnect maybe
ssbClient(keys, 'appname')
works fine, however if you are wanting to pass your own config in (e.g. ssbClient(keys, ssbConfig('appname', { port: 12345 }))
), everything breaks.
It seems there is something fishy going on here.
config
is set to {}
and the options are basically thrown away.
I want to use ssb-client without passing keys or opts, like this:
// $ export ssb_appname=testing
ssbClient((err, sbot) => {
// fails to connect because it uses .testing/config but not the appKey/shs caps
})
It should use ssb-config which checks ssb_appname
. In that case ssb-client falls back to the still hardcoded caps..
I saw #15 and wonder if we can merge a rebased version of it? or say that if you supply opts it has to have appKey? All the cases juggling between opts and config make my head spin...
There are several modules intertwined here, so I'm posting this here since this I think is the top module in the dependency graph I think.
This is me trying to start a ssb-server2
module, being a library that provides a CLI interface and daemon-like process for ssb, like ssb-server.
I started by more-or-less copying the structure of ssb-server
-- https://github.com/planetary-social/ssb-server2/blob/efbbe600294695893551384981a6faa771a5091d/bin.js#L99
The call to ssb-client
:
Client(config.keys, opts, (err, rpc) => {
However I am stuck with this error when I start the server then try calling a method:
stack: 'Error: method:db,getStatus is not in list of allowed methods\n' +
This is after running NODE_ENV=test node ./bin.js start -- --path=./test-data
in one terminal, then doing NODE_ENV=test node ./bin.js db.getStatus -- --path=./test-data
in another terminal.
I feel like I need to do something with secret-handshake in order for this to work, but I'm not sure.
I'm trying to run this in the browser, but it's failing when it can't find manifest.json
. Is there a known workaround for this? I'm sure the fs.readFileSync()
is being polyfilled, but I'm unsure how to actually generate manifest.json
. Thanks!
Most of sbot ecosystem is controlled by the ssb_appname
env var, which tells you which dot-dir in the home to store data and load config.
It would be super handy if you could just specify the appname in ssb-client:
ssbClient('myappname', function (err, sbot) {
// ...
})
cc @dominictarr @NHQ
I see an sbot.closed
flag, and there's a sbot.on
which adds to sbot._events
, but it doesn't seem as though anything gets fired when closed changes from false
-> true
.
I can work around this with a setInterval, but if this functionality exists I'd rather use it. Am I missing something?
haven't looked into it enough to know what the difference is but I think someone forgot to push to GitHub
New in 4.7.0?
ReferenceError: explain is not defined
at /home/christianbundy/src/redacted/node_modules/ssb-client/client.js:69:13
at /home/christianbundy/src/redacted/node_modules/multiserver/compose.js:80:24
at onConnect (/home/christianbundy/src/redactednode_modules/multiserver/plugins/ws.js:93:11)
at WebSocket.<anonymous> (/home/christianbundy/src/redactednode_modules/pull-ws/source.js:49:13)
at WebSocket.onError (/home/christianbundy/src/redacted/node_modules/ws/lib/WebSocket.js:452:14)
at WebSocket.emit (events.js:197:13)
at ClientRequest.onerror (/home/christianbundy/src/redacted/node_modules/ws/lib/WebSocket.js:711:10)
at ClientRequest.emit (events.js:197:13)
at Socket.socketErrorListener (_http_client.js:397:9)
at Socket.emit (events.js:197:13)
multiserver error
did a version change introduce this?
reproduce:
https://github.com/nichoth/eventual/tree/ee18e417f306f907bdd413ef442193b9e29c037f
npm start
What would you think of putting the .auth call into .connect, and having the auth object be passed into .connect? So:
var client = SSBClient({ host: 'localhost' })
client.connect(abortIf)
client.auth(SSBKeys.createAuth(keys), abortIf)
becomes
var client = SSBClient({ host: 'localhost' })
client.connect(SSBKeys.createAuth(keys), abortIf)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.