dustin / go-coap

Implementation of CoAP in go.
MIT License
341 stars 103 forks source link

panic occured! #16

Closed zhaohui-kevin closed 9 years ago

zhaohui-kevin commented 9 years ago

When I try coap-client connect to coap-server(in example) panic is occured! (In Go1.4)

panic: invalid type for option 8: []string ([some path])

goroutine 5 [running]: github.com/dustin/go-coap.option.toBytes(0x8, 0x4f7660, 0xc20801e280, 0x0, 0x0, 0x0) /home/work/gosrc/src/github.com/dustin/go-coap/message.go:242 +0x32b github.com/dustin/go-coap.(*Message).MarshalBinary(0xc20803c320, 0x0, 0x0, 0x0, 0x0, 0x0) /home/work/gosrc/src/github.com/dustin/go-coap/message.go:410 +0x315 github.com/dustin/go-coap.Transmit(0xc208038028, 0xc20803a3f0, 0x30394502, 0x0, 0x0, 0x0, 0xc208045290, 0xd, 0x10, 0xc20803a480, ...) /home/work/gosrc/src/github.com/dustin/go-coap/server.go:47 +0x6b github.com/dustin/go-coap.handlePacket(0xc208038028, 0xc20803a420, 0x25, 0x25, 0xc20803a3f0, 0x7f9238a8ab18, 0x597fb0) /home/work/gosrc/src/github.com/dustin/go-coap/server.go:41 +0x30b created by github.com/dustin/go-coap.ListenAndServe /home/work/gosrc/src/github.com/dustin/go-coap/server.go:89 +0x2de

goroutine 1 [IO wait]: net.(_pollDesc).Wait(0xc2080100d0, 0x72, 0x0, 0x0) /home/work/go/src/net/fd_poll_runtime.go:84 +0x47 net.(_pollDesc).WaitRead(0xc2080100d0, 0x0, 0x0) /home/work/go/src/net/fd_poll_runtime.go:89 +0x43 net.(_netFD).readFrom(0xc208010070, 0xc20805686c, 0x5dc, 0x5dc, 0x0, 0x0, 0x0, 0x7f9238a8aac8, 0xc2080450a0) /home/work/go/src/net/fd_unix.go:269 +0x4a1 net.(_UDPConn).ReadFromUDP(0xc208038028, 0xc20805686c, 0x5dc, 0x5dc, 0xc20803a3f0, 0x0, 0x0, 0x0) /home/work/go/src/net/udpsock_posix.go:67 +0x124 github.com/dustin/go-coap.ListenAndServe(0x55f730, 0x3, 0x556d10, 0x5, 0x7f9238a8ab18, 0x597fb0, 0x0, 0x0) /home/work/gosrc/src/github.com/dustin/go-coap/server.go:85 +0x19c main.main() /home/work/gosrc/src/github.com/dustin/go-coap/example/server/coap_server.go:27 +0xa5 exit status 2

dustin commented 9 years ago

Do you have example code that leads to this?

On Sun, Dec 28, 2014, 07:46 zhaohui-kevin notifications@github.com wrote:

When I try coap-client connect to coap-server(in example) panic is occured! (In Go1.4)

panic: invalid type for option 8: []string ([some path])

goroutine 5 [running]: github.com/dustin/go-coap.option.toBytes(0x8, 0x4f7660, 0xc20801e280, 0x0, 0x0, 0x0) /home/work/gosrc/src/github.com/dustin/go-coap/message.go:242 +0x32b github.com/dustin/go-coap.(*Message).MarshalBinary(0xc20803c320, 0x0, 0x0, 0x0, 0x0, 0x0) /home/work/gosrc/src/github.com/dustin/go-coap/message.go:410 +0x315 github.com/dustin/go-coap.Transmit(0xc208038028, 0xc20803a3f0, 0x30394502, 0x0, 0x0, 0x0, 0xc208045290, 0xd, 0x10, 0xc20803a480, ...) /home/work/gosrc/src/github.com/dustin/go-coap/server.go:47 +0x6b github.com/dustin/go-coap.handlePacket(0xc208038028, 0xc20803a420, 0x25, 0x25, 0xc20803a3f0, 0x7f9238a8ab18, 0x597fb0) /home/work/gosrc/src/github.com/dustin/go-coap/server.go:41 +0x30b created by github.com/dustin/go-coap.ListenAndServe /home/work/gosrc/src/github.com/dustin/go-coap/server.go:89 +0x2de

goroutine 1 [IO wait]: net.(

_pollDesc).Wait(0xc2080100d0, 0x72, 0x0, 0x0) /home/work/go/src/net/fd_poll_runtime.go:84 +0x47 net.(_pollDesc).WaitRead(0xc2080100d0, 0x0, 0x0) /home/work/go/src/net/fd_poll_runtime.go:89 +0x43 net.(

_netFD).readFrom(0xc208010070, 0xc20805686c, 0x5dc, 0x5dc, 0x0, 0x0, 0x0, 0x7f9238a8aac8, 0xc2080450a0) /home/work/go/src/net/fd_unix.go:269 +0x4a1 net.(_UDPConn).ReadFromUDP(0xc208038028, 0xc20805686c, 0x5dc, 0x5dc, 0xc20803a3f0, 0x0, 0x0, 0x0) /home/work/go/src/net/udpsock_posix.go:67 +0x124 github.com/dustin/go-coap.ListenAndServe(0x55f730, 0x3, 0x556d10, 0x5, 0x7f9238a8ab18, 0x597fb0, 0x0, 0x0) /home/work/gosrc/src/github.com/dustin/go-coap/server.go:85 +0x19c main.main() /home/work/gosrc/src/ github.com/dustin/go-coap/example/server/coap_server.go:27 +0xa5 exit status 2

— Reply to this email directly or view it on GitHub https://github.com/dustin/go-coap/issues/16.

zhaohui-kevin commented 9 years ago

Hi, I just run the /example/client/goap_client.go and /example/server/coap_server.go; but error occured

dustin commented 9 years ago

Thanks. Found it, wrote a test, etc...

On Sun Dec 28 2014 at 9:43:34 PM zhaohui-kevin notifications@github.com wrote:

Hi, I just run the /example/client/goap_client.go and /example/server/coap_server.go; but error occured

— Reply to this email directly or view it on GitHub https://github.com/dustin/go-coap/issues/16#issuecomment-68233784.

zhaohui-kevin commented 9 years ago

Hi Dustin, thanks very much!! and your picture is very cool!