siku2 / arigo Goto Github PK
View Code? Open in Web Editor NEWaria2 client for go
License: MIT License
aria2 client for go
License: MIT License
I write a example like that:
package main
import (
aria2 "github.com/siku2/arigo"
)
func Get() error {
url := "ws://127.0.0.1:6800/jsonrpc"
conn, err := aria2.Dial(url, "")
if err != nil {
return err
}
defer conn.Close()
if _, err := conn.TellActive("gid"); err != nil {
return err
}
return nil
}
func main() {
for {
if err := Get(); err != nil {
panic(err)
}
}
}
And got panic:
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0xc0 pc=0x63757d]
goroutine 34 [running]:
github.com/gorilla/websocket.(*Conn).NextReader(0x0)
/root/go/pkg/mod/github.com/gorilla/[email protected]/conn.go:1000 +0x1d
github.com/siku2/arigo/internal/pkg/wsrpc.(*ReadWriteCloser).Read(0xc0002061b0, {0xc0001a0200, 0x200, 0x200})
/root/go/pkg/mod/github.com/siku2/[email protected]/internal/pkg/wsrpc/rwc.go:26 +0x45
encoding/json.(*Decoder).refill(0xc00022e000)
/usr/local/go/src/encoding/json/stream.go:165 +0x188
encoding/json.(*Decoder).readValue(0xc00022e000)
/usr/local/go/src/encoding/json/stream.go:140 +0xbb
encoding/json.(*Decoder).Decode(0xc00022e000, {0x652b20, 0xc000230020})
/usr/local/go/src/encoding/json/stream.go:63 +0x78
github.com/cenkalti/rpc2/jsonrpc.(*jsonCodec).ReadHeader(0xc000230000, 0xc0000121c8, 0xc0000121e0)
/root/go/pkg/mod/github.com/cenkalti/[email protected]/jsonrpc/jsonrpc.go:93 +0x85
github.com/cenkalti/rpc2.(*Client).readLoop(0xc000216070)
/root/go/pkg/mod/github.com/cenkalti/[email protected]/client.go:87 +0x12d
github.com/cenkalti/rpc2.(*Client).Run(...)
/root/go/pkg/mod/github.com/cenkalti/[email protected]/client.go:62
github.com/siku2/arigo.(*Client).Run(0x0?)
/root/go/pkg/mod/github.com/siku2/[email protected]/client.go:97 +0x1c
created by github.com/siku2/arigo.DialContext
/root/go/pkg/mod/github.com/siku2/[email protected]/client.go:82 +0x40a
exit status 2
Maybe we shoule use a Mutex to protect the websocket from reading after it was closed?
is it possible to get GID just after adding the url instead of getting it after complete download?
When first time call Client.Subscribe
, it registers two function, the first one is nil, which causes crash when this event triggers.
The logic from source:
func (c *Client) Subscribe(name string, listener EventListener) {
listeners, ok := c.listeners[name]
if !ok {
listeners = make([]EventListener, 1)
c.listeners[name] = listeners
}
c.listeners[name] = append(listeners, listener)
}
Should be:
func (c *Client) Subscribe(name string, listener EventListener) {
listeners, ok := c.listeners[name]
if !ok {
c.listeners[name] = []EventListener{listener}
} else {
c.listeners[name] = append(listeners, listener)
}
}
hi team.
i use your readme example, file downloaded from remote server but not return event done download to my Go code.
please help me thanks.
It can successfully add the file and download it, but with this error, of course no status back after running into the error.
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.