goczmq is a golang wrapper for CZMQ.

Related tags

Messaging goczmq
Overview

goczmq Build Status Doc Status

Introduction

A golang interface to the CZMQ v4.2 API.

Install

Dependencies

For CZMQ master

go get github.com/zeromq/goczmq

A Note on Build Tags

The CZMQ library includes experimental classes that are not built by default, but can be built by passing --enable-drafts to configure. Support for these draft classes are being added to goczmq. To build these features against a CZMQ that has been compiled with --enable-drafts, use go build -tags draft.

For CMZQ = 4.2

go get gopkg.in/zeromq/goczmq.v4

Note: CZMQ 4.2 is has not been released yet.

For CZMQ Before 4.0

go get gopkg.in/zeromq/goczmq.v1

Usage

Direct CZMQ Sock API

Example

package main

import (
	"log"

	"github.com/zeromq/goczmq"
)

func main() {
	// Create a router socket and bind it to port 5555.
	router, err := goczmq.NewRouter("tcp://*:5555")
	if err != nil {
		log.Fatal(err)
	}
	defer router.Destroy()

	log.Println("router created and bound")

	// Create a dealer socket and connect it to the router.
	dealer, err := goczmq.NewDealer("tcp://127.0.0.1:5555")
	if err != nil {
		log.Fatal(err)
	}
	defer dealer.Destroy()

	log.Println("dealer created and connected")

	// Send a 'Hello' message from the dealer to the router.
	// Here we send it as a frame ([]byte), with a FlagNone
	// flag to indicate there are no more frames following.
	err = dealer.SendFrame([]byte("Hello"), goczmq.FlagNone)
	if err != nil {
		log.Fatal(err)
	}

	log.Println("dealer sent 'Hello'")

	// Receve the message. Here we call RecvMessage, which
	// will return the message as a slice of frames ([][]byte).
	// Since this is a router socket that support async
	// request / reply, the first frame of the message will
	// be the routing frame.
	request, err := router.RecvMessage()
	if err != nil {
		log.Fatal(err)
	}

	log.Printf("router received '%s' from '%v'", request[1], request[0])

	// Send a reply. First we send the routing frame, which
	// lets the dealer know which client to send the message.
	// The FlagMore flag tells the router there will be more
	// frames in this message.
	err = router.SendFrame(request[0], goczmq.FlagMore)
	if err != nil {
		log.Fatal(err)
	}

	log.Printf("router sent 'World'")

	// Next send the reply. The FlagNone flag tells the router
	// that this is the last frame of the message.
	err = router.SendFrame([]byte("World"), goczmq.FlagNone)
	if err != nil {
		log.Fatal(err)
	}

	// Receive the reply.
	reply, err := dealer.RecvMessage()
	if err != nil {
		log.Fatal(err)
	}

	log.Printf("dealer received '%s'", string(reply[0]))
}

Output

2015/05/26 21:52:52 router created and bound
2015/05/26 21:52:52 dealer created and connected
2015/05/26 21:52:52 dealer sent 'Hello'
2015/05/26 21:52:52 router received 'Hello' from '[0 103 84 189 175]'
2015/05/26 21:52:52 router sent 'World'
2015/05/26 21:52:52 dealer received 'World'

io.ReadWriter support

Example

package main

import (
	"log"

	"github.com/zeromq/goczmq"
)

func main() {
	// Create a router socket and bind it to port 5555.
	router, err := goczmq.NewRouter("tcp://*:5555")
	if err != nil {
		log.Fatal(err)
	}
	defer router.Destroy()

	log.Println("router created and bound")

	// Create a dealer socket and connect it to the router.
	dealer, err := goczmq.NewDealer("tcp://127.0.0.1:5555")
	if err != nil {
		log.Fatal(err)
	}
	defer dealer.Destroy()

	log.Println("dealer created and connected")

	// Send a 'Hello' message from the dealer to the router,
	// using the io.Write interface
	n, err := dealer.Write([]byte("Hello"))
	if err != nil {
		log.Fatal(err)
	}

	log.Printf("dealer sent %d byte message 'Hello'\n", n)

	// Make a byte slice and pass it to the router
	// Read interface. When using the ReadWriter
	// interface with a router socket, the router
	// caches the routing frames internally in a
	// FIFO and uses them transparently when
	// sending replies.
	buf := make([]byte, 16386)

	n, err = router.Read(buf)
	if err != nil {
		log.Fatal(err)
	}

	log.Printf("router received '%s'\n", buf[:n])

	// Send a reply.
	n, err = router.Write([]byte("World"))
	if err != nil {
		log.Fatal(err)
	}

	log.Printf("router sent %d byte message 'World'\n", n)

	// Receive the reply, reusing the previous buffer.
	n, err = dealer.Read(buf)
	if err != nil {
		log.Fatal(err)
	}

	log.Printf("dealer received '%s'", string(buf[:n]))
}

Output

2015/05/26 21:54:10 router created and bound
2015/05/26 21:54:10 dealer created and connected
2015/05/26 21:54:10 dealer sent 5 byte message 'Hello'
2015/05/26 21:54:10 router received 'Hello'
2015/05/26 21:54:10 router sent 5 byte message 'World'
2015/05/26 21:54:10 dealer received 'World'

Thread safe channel interface

Example

package main

import (
	"log"

	"github.com/zeromq/goczmq"
)

func main() {
	// Create a router channeler and bind it to port 5555.
	// A channeler provides a thread safe channel interface
	// to a *Sock
	router := goczmq.NewRouterChanneler("tcp://*:5555")
	defer router.Destroy()

	log.Println("router created and bound")

	// Create a dealer channeler and connect it to the router.
	dealer := goczmq.NewDealerChanneler("tcp://127.0.0.1:5555")
	defer dealer.Destroy()

	log.Println("dealer created and connected")

	// Send a 'Hello' message from the dealer to the router.
	dealer.SendChan <- [][]byte{[]byte("Hello")}
	log.Println("dealer sent 'Hello'")

	// Receve the message as a [][]byte. Since this is
	// a router, the first frame of the message wil
	// be the routing frame.
	request := <-router.RecvChan
	log.Printf("router received '%s' from '%v'", request[1], request[0])

	// Send a reply. First we send the routing frame, which
	// lets the dealer know which client to send the message.
	router.SendChan <- [][]byte{request[0], []byte("World")}
	log.Printf("router sent 'World'")

	// Receive the reply.
	reply := <-dealer.RecvChan
	log.Printf("dealer received '%s'", string(reply[0]))
}

Output

2015/05/26 21:56:43 router created and bound
2015/05/26 21:56:43 dealer created and connected
2015/05/26 21:56:43 dealer sent 'Hello'
2015/05/26 21:56:43 received 'Hello' from '[0 12 109 153 35]'
2015/05/26 21:56:43 router sent 'World'
2015/05/26 21:56:43 dealer received 'World'

GoDoc

godoc

See Also

License

This project uses the MPL v2 license, see LICENSE

Issues
  • go get fails

    go get fails

    Hi, I'm doing go get gopkg.in/zeromq/goczmq.v4 and I get the following:

    # pkg-config --cflags libczmq libzmq libsodium
    Package libczmq was not found in the pkg-config search path.
    Perhaps you should add the directory containing `libczmq.pc'
    to the PKG_CONFIG_PATH environment variable
    No package 'libczmq' found
    Package libsodium was not found in the pkg-config search path.
    Perhaps you should add the directory containing `libsodium.pc'
    to the PKG_CONFIG_PATH environment variable
    No package 'libsodium' found
    pkg-config: exit status 1
    
    

    But when I do apt-get install libzmq-dev I see that the package already exists. Should this fail and I fix it manually or this is a real issue? Sorry if not, but I think it should be automatic.

    opened by lattice0 12
  • NewROUTER fails when hostname is 'localhost'

    NewROUTER fails when hostname is 'localhost'

    The following line fails:

    routerSock, err := czmq.NewROUTER("tcp://localhost:5559")

    And the error message is:

    goroutine 16 [running]:
    runtime.panic(0x40c2f80, 0xc208000190)
            /usr/local/go/src/pkg/runtime/panic.c:279 +0xf5
    main.main()
            /Users/dhanush/golang/src/github.com/zeromq/goczmq/examples/extended-req-rep/rrbroker.go:15 +0x176
    
    goroutine 17 [runnable]:
    runtime.MHeap_Scavenger()
            /usr/local/go/src/pkg/runtime/mheap.c:507
    runtime.goexit()
            /usr/local/go/src/pkg/runtime/proc.c:1445
    
    goroutine 18 [runnable]:
    bgsweep()
            /usr/local/go/src/pkg/runtime/mgc0.c:1976
    runtime.goexit()
            /usr/local/go/src/pkg/runtime/proc.c:1445
    
    goroutine 19 [runnable]:
    runfinq()
            /usr/local/go/src/pkg/runtime/mgc0.c:2606
    runtime.goexit()
            /usr/local/go/src/pkg/runtime/proc.c:1445
    
    goroutine 17 [syscall]:
    runtime.goexit()
            /usr/local/go/src/pkg/runtime/proc.c:1445
    exit status 2
    

    My code lives here: http://play.golang.org/p/vP1qLyxYwx

    opened by indradhanush 11
  • Problem: assertion failure on windows

    Problem: assertion failure on windows

    When running the unit tests on windows (compiling with Mingw), this results in the following output:

    $ go test -v
    === RUN TestBeacon
    I: 14-10-14 10:17:31 zbeacon: API command=CONFIGURE
    I: 14-10-14 10:17:31 zbeacon: using address=192.168.1.4 broadcast=192.168.1.255
    I: 14-10-14 10:17:31 zbeacon: configured, hostname=192.168.1.4
    I: 14-10-14 10:17:31 zbeacon: API command=CONFIGURE
    I: 14-10-14 10:17:31 zbeacon: using address=192.168.1.4 broadcast=192.168.1.255
    I: 14-10-14 10:17:31 zbeacon: configured, hostname=192.168.1.4
    I: 14-10-14 10:17:31 zbeacon: API command=SUBSCRIBE
    I: 14-10-14 10:17:31 zbeacon: API command=PUBLISH
    I: 14-10-14 10:17:31 zbeacon: API command=$TERM
    I: 14-10-14 10:17:31 zbeacon: API command=$TERM
    --- PASS: TestBeacon (0.01 seconds)
            beacon_test.go:39: 192.168.1.4
    === RUN TestGossip
    D: 14-10-14 10:17:31 server:     API command=BIND
    D: 14-10-14 10:17:31 server:     API command=$TERM
    --- PASS: TestGossip (0.02 seconds)
    === RUN TestPoller
    --- PASS: TestPoller (0.00 seconds)
    === RUN TestZproxy
    I: 14-10-14 10:17:31 zproxy: API command=FRONTEND
    I: 14-10-14 10:17:31 zmonitor: - frontend type=PULL attach=inproc://frontend
    I: 14-10-14 10:17:31 zproxy: API command=BACKEND
    I: 14-10-14 10:17:31 zmonitor: - backend type=PUSH attach=inproc://backend
    I: 14-10-14 10:17:31 zproxy: API command=CAPTURE
    I: 14-10-14 10:17:31 zproxy: API command=PAUSE
    --- PASS: TestZproxy (0.00 seconds)
    I: 14-10-14 10:17:31 zproxy: API command=RESUME
    === RUN TestTos
    --- PASS: TestTos (0.00 seconds)
    === RUN TestRouterHandover
    --- PASS: TestRouterHandover (0.00 seconds)
    === RUN TestRouterMandatory
    --- PASS: TestRouterMandatory (0.00 seconds)
    === RUN TestProbeRouter
    --- PASS: TestProbeRouter (0.00 seconds)
    === RUN TestReqRelaxed
    --- PASS: TestReqRelaxed (0.00 seconds)
    === RUN TestReqCorrelate
    --- PASS: TestReqCorrelate (0.00 seconds)
    === RUN TestConflate
    --- PASS: TestConflate (0.00 seconds)
    === RUN TestZapDomain
    --- PASS: TestZapDomain (0.00 seconds)
    === RUN TestPlainServer
    --- PASS: TestPlainServer (0.00 seconds)
    === RUN TestPlainUsername
    --- PASS: TestPlainUsername (0.00 seconds)
    === RUN TestPlainPassword
    --- PASS: TestPlainPassword (0.00 seconds)
    === RUN TestIpv6
    --- PASS: TestIpv6 (0.00 seconds)
    === RUN TestImmediate
    --- PASS: TestImmediate (0.00 seconds)
    === RUN TestRouterRaw
    --- PASS: TestRouterRaw (0.00 seconds)
    === RUN TestIpv4only
    --- PASS: TestIpv4only (0.00 seconds)
    === RUN TestDelayAttachOnConnect
    --- PASS: TestDelayAttachOnConnect (0.00 seconds)
    === RUN TestSndhwm
    --- PASS: TestSndhwm (0.00 seconds)
    === RUN TestRcvhwm
    --- PASS: TestRcvhwm (0.00 seconds)
    === RUN TestAffinity
    --- PASS: TestAffinity (0.00 seconds)
    === RUN TestSubscribe
    --- PASS: TestSubscribe (0.00 seconds)
    === RUN TestUnsubscribe
    --- PASS: TestUnsubscribe (0.00 seconds)
    === RUN TestIdentity
    --- PASS: TestIdentity (0.00 seconds)
    === RUN TestRate
    --- PASS: TestRate (0.00 seconds)
    === RUN TestRecoveryIvl
    --- PASS: TestRecoveryIvl (0.00 seconds)
    === RUN TestSndbuf
    --- PASS: TestSndbuf (0.00 seconds)
    === RUN TestRcvbuf
    --- PASS: TestRcvbuf (0.00 seconds)
    === RUN TestLinger
    --- PASS: TestLinger (0.00 seconds)
    === RUN TestReconnectIvl
    --- PASS: TestReconnectIvl (0.00 seconds)
    === RUN TestReconnectIvlMax
    --- PASS: TestReconnectIvlMax (0.00 seconds)
    === RUN TestBacklog
    --- PASS: TestBacklog (0.00 seconds)
    === RUN TestMaxmsgsize
    --- PASS: TestMaxmsgsize (0.00 seconds)
    === RUN TestMulticastHops
    --- PASS: TestMulticastHops (0.00 seconds)
    === RUN TestRcvtimeo
    --- PASS: TestRcvtimeo (0.00 seconds)
    === RUN TestSndtimeo
    --- PASS: TestSndtimeo (0.00 seconds)
    === RUN TestXpubVerbose
    --- PASS: TestXpubVerbose (0.00 seconds)
    === RUN TestTcpKeepalive
    --- PASS: TestTcpKeepalive (0.00 seconds)
    === RUN TestTcpKeepaliveIdle
    --- PASS: TestTcpKeepaliveIdle (0.00 seconds)
    === RUN TestTcpKeepaliveCnt
    --- PASS: TestTcpKeepaliveCnt (0.00 seconds)
    === RUN TestTcpKeepaliveIntvl
    --- PASS: TestTcpKeepaliveIntvl (0.00 seconds)
    === RUN TestTcpAcceptFilter
    --- PASS: TestTcpAcceptFilter (0.00 seconds)
    === RUN TestSock
    --- PASS: TestSock (0.00 seconds)
    === RUN TestMessage
    --- PASS: TestMessage (0.00 seconds)
    === RUN TestPUBSUB
    --- PASS: TestPUBSUB (0.00 seconds)
    === RUN TestREQREP
    --- PASS: TestREQREP (0.00 seconds)
    === RUN TestPUSHPULL
    --- PASS: TestPUSHPULL (0.00 seconds)
    === RUN TestROUTERDEALER
    --- PASS: TestROUTERDEALER (0.00 seconds)
    === RUN TestXSUBXPUB
    --- PASS: TestXSUBXPUB (0.00 seconds)
    === RUN TestPAIR
    --- PASS: TestPAIR (0.00 seconds)
    === RUN TestSTREAM
    --- PASS: TestSTREAM (0.00 seconds)
    === RUN TestPollin
    --- PASS: TestPollin (0.00 seconds)
    === RUN TestPollout
    --- PASS: TestPollout (0.00 seconds)
    PASS
    E: 14-10-14 10:17:31 dangling 'PULL' socket created at C:/Synced/PSG/go-workspace/src/github.com/zeromq/goczmq/sock.go:118
    Assertion failed: Successful WSASTARTUP not yet performed (signaler.cpp:183)
    exit status 255
    FAIL    github.com/zeromq/goczmq        5.823s
    
    opened by luna-duclos 8
  • Problem: I want to make backwards incompatible changes.

    Problem: I want to make backwards incompatible changes.

    I would like to start adding support for the new thread safe sockets to goczmq:

    • ZMQ_RADAR / ZMQ_DISH
    • ZMQ_SCATTER / ZMQ_GATHER
    • ZMQ_CLIENT / ZMQ_SERVER

    This would of course break building goczmq against the current stable release of libzmq and czmq.

    I am thinking about using gopkg.in ( http://labix.org/gopkg.in ) to handle this, the same way oliver's elastic library does for dealing with multiple incompatible versions of the elasticsearch API ( see: https://github.com/olivere/elastic ).

    I'm putting this issue here to solicit feedback and give a heads up.

    question 
    opened by taotetek 7
  • Problem: Beacon should return address and beacon as single message

    Problem: Beacon should return address and beacon as single message

    Details: See https://github.com/zeromq/goczmq/issues/151 Solution: Fix beacon to return address and beacon as single message

    Note: this does change the return type of (b *Beacon) Recv(timeout int) from string to [][]byte. In this case I believe the fix warrants this change as the original Recv call didn't match the Beacon implementation in CZMQ.

    opened by taotetek 7
  • Thread Safe Channels Example Fails

    Thread Safe Channels Example Fails

    $ go run thread_safe_channel.go
    2015/08/16 09:57:27 router created and bound
    2015/08/16 09:57:27 dealer created and connected
    Assertion failed: (!s_process_ctx), function zsys_init, file src/zsys.c, line 179.
    SIGABRT: abort
    PC=0x7fff9510f286
    signal arrived during cgo execution
    
    goroutine 6 [syscall, locked to thread]:
    runtime.cgocall_errno(0x4001850, 0xc208059cf0, 0x0)
        /usr/local/Cellar/go/1.4.2/libexec/src/runtime/cgocall.go:130 +0xf5 fp=0xc208059cd0 sp=0xc208059ca8
    github.com/zeromq/goczmq._Cfunc_zsock_new_checked(0x0, 0x5000200, 0xdb, 0x0)
        github.com/zeromq/goczmq/_obj/_cgo_gotypes.go:479 +0x44 fp=0xc208059cf0 sp=0xc208059cd0
    github.com/zeromq/goczmq.NewSock(0x0, 0xc20803a300)
        /Users/kyle6475/code/src/github.com/zeromq/goczmq/sock.go:81 +0x189 fp=0xc208059d68 sp=0xc208059cf0
    github.com/zeromq/goczmq.NewPair(0xc20803a300, 0x29, 0xc208059e98, 0x0, 0x0)
        /Users/kyle6475/code/src/github.com/zeromq/goczmq/sock.go:219 +0x39 fp=0xc208059da8 sp=0xc208059d68
    github.com/zeromq/goczmq.(*Channeler).actor(0xc208010070, 0xc2080500c0)
        /Users/kyle6475/code/src/github.com/zeromq/goczmq/channeler.go:35 +0x141 fp=0xc208059fd0 sp=0xc208059da8
    runtime.goexit()
        /usr/local/Cellar/go/1.4.2/libexec/src/runtime/asm_amd64.s:2232 +0x1 fp=0xc208059fd8 sp=0xc208059fd0
    created by github.com/zeromq/goczmq.newChanneler
        /Users/kyle6475/code/src/github.com/zeromq/goczmq/channeler.go:186 +0x45b
    
    goroutine 1 [chan send]:
    main.main()
        /Users/kyle6475/code/src/github.com/rgbkrk/junkie/thread_safe_channel.go:25 +0x2fe
    
    goroutine 5 [syscall, locked to thread]:
    github.com/zeromq/goczmq._Cfunc_zsock_attach(0x5000470, 0x54003c0, 0x5400300, 0x0)
        github.com/zeromq/goczmq/_obj/_cgo_gotypes.go:347 +0x43
    github.com/zeromq/goczmq.(*Sock).Attach(0xc20805bfa8, 0x2, 0x2, 0x4016062, 0xc20805bf30, 0x0)
        /Users/kyle6475/code/src/github.com/zeromq/goczmq/sock.go:132 +0x68
    created by github.com/zeromq/goczmq.newChanneler
        /Users/kyle6475/code/src/github.com/zeromq/goczmq/channeler.go:185 +0x437
    
    goroutine 17 [syscall, locked to thread]:
    runtime.goexit()
        /usr/local/Cellar/go/1.4.2/libexec/src/runtime/asm_amd64.s:2232 +0x1
    
    goroutine 7 [runnable, locked to thread]:
    github.com/zeromq/goczmq._Cfunc_zsock_attach(0x5200040, 0x52000e0, 0x5200000, 0x0)
        github.com/zeromq/goczmq/_obj/_cgo_gotypes.go:347 +0x43
    github.com/zeromq/goczmq.(*Sock).Attach(0xc208034300, 0xc20803a2d0, 0x21, 0x0, 0x0, 0x0)
        /Users/kyle6475/code/src/github.com/zeromq/goczmq/sock.go:132 +0x68
    github.com/zeromq/goczmq.NewPush(0x40f94b0, 0x3, 0xc208054ed8, 0x1, 0x1)
        /Users/kyle6475/code/src/github.com/zeromq/goczmq/sock.go:185 +0x65
    github.com/zeromq/goczmq.(*Channeler).channeler(0xc2080100e0, 0xc208050180, 0xc2080501e0)
        /Users/kyle6475/code/src/github.com/zeromq/goczmq/channeler.go:127 +0x4b
    created by github.com/zeromq/goczmq.newChanneler
        /Users/kyle6475/code/src/github.com/zeromq/goczmq/channeler.go:185 +0x437
    2015/08/16 09:57:27 dealer sent 'Hello'
    
    goroutine 8 [syscall, locked to thread]:
    github.com/zeromq/goczmq._Cfunc_zframe_recv(0x52003d0, 0x0)
        github.com/zeromq/goczmq/_obj/_cgo_gotypes.go:305 +0x44
    github.com/zeromq/goczmq.(*Sock).RecvFrame(0x0, 0x404307a, 0x5200860, 0xffffffff, 0x0, 0x1, 0x1)
        /Users/kyle6475/code/src/github.com/zeromq/goczmq/sock.go:268 +0x72
    created by github.com/zeromq/goczmq.newChanneler
        /Users/kyle6475/code/src/github.com/zeromq/goczmq/channeler.go:186 +0x45b
    
    rax     0x0
    rbx     0x6
    rcx     0x7fff5fbfea58
    rdx     0x0
    rdi     0x30b
    rsi     0x6
    rbp     0x7fff5fbfea80
    rsp     0x7fff5fbfea58
    r8      0x0
    r9      0xb3
    r10     0x8000000
    r11     0x206
    r12     0x422303c
    r13     0x4370000
    r14     0x7fff7846b300
    r15     0x4222f8b
    rip     0x7fff9510f286
    rflags  0x206
    cs      0x7
    fs      0x0
    gs      0x0
    exit status 2
    
    question 
    opened by rgbkrk 6
  • Failure to go get

    Failure to go get

    Hi folks,

    I'm seeing this when I go get this package:

    $ go get github.com/zeromq/goczmq

    github.com/zeromq/goczmq

    could not determine kind of name for C.zsock_destroy_checked could not determine kind of name for C.zsock_new_checked

    I'm sure I'm doing something wrong, but have no idea where to begin to track the problem.

    Here's my go version: $ go version go version go1.4.2 linux/amd64

    Thanks!

    -chuck

    opened by chuckprice 6
  • Problem: No Nice Consistent Way For Dealing Wth Bytes and Strings

    Problem: No Nice Consistent Way For Dealing Wth Bytes and Strings

    Overview:

    • RecvBytes returns a []byte, flag, error
    • RecvString returns string, error and no flag

    These are inconsistent, and RecvString should return a more flag to be usable with multi part messages.

    • RecvMessage returns a full message as [][]bytes (and an error)
    • RecvMultiString returns a full message as a []string and an error

    These are consistent, but the names are not so wonderful.

    • Channeler returns a channel of [][]byte messages, which is great - but any person who would like to get []string back from Channeler will need to write a little code - yesterday we discussed that we could make some utility functions for transposing between [][]byte <-> []string when working with Channeler.

    Thoughts:

    • The utility functions for working with Channeler won't break anything, they are additions.
    • RecvMessage / RecvMultiString should be named something more consistent, like RecvBytesMessage / RecvStringsMessage (I probably am bad at naming things). This is a breaking change so we should discuss
    • RecvString should be changed to return string, flag, err like RecvBytes. This is a breaking change so we shold discuss

    Thoughts from others welcome, this is just my early morning coffee thoughts on this.

    enhancement question 
    opened by taotetek 6
  • goczmq prevents signals from being received

    goczmq prevents signals from being received

    When any socket is initialized using goczmq, signal.Notify ceases working and no signals will ever be received on the notify channel

    Code:

    package main
    
    import (
        "fmt"
        "os"
        "os/signal"
        "syscall"
    
        zmq "github.com/zeromq/goczmq"
    )
    
    func main() {
        // Signal notifiers
        c := make(chan os.Signal, 2)
        signal.Notify(c, os.Interrupt, syscall.SIGTERM)
    
        _, _ = zmq.NewROUTER(">tcp://0.0.0.0:*")
    
        <-c
        fmt.Println("Done")
    }
    
    

    if zmq.NewROUTER is removed and the zmq import removed, the signal handler will work again

    opened by luna-duclos 6
  • Problem: CZMQ 4.2 is required, not just 4.0+

    Problem: CZMQ 4.2 is required, not just 4.0+

    Problem

    Documentation states that the code will work with CZMQ 4.x+ However, this does not seem to be the case.

    Versions Pulled

    {                                                               
        "checksumSHA1": "nnlv7YDAEQZv0XMm4CMgMaJJnAA=",         
         "path": "gopkg.in/zeromq/goczmq.v4",                    
         "revision": "98ab09146269d98bc3e427046f5fc222c4134e0b", 
         "revisionTime": "2017-10-08T14:05:00Z"                  
    }  
    
     {                                                               
         "checksumSHA1": "7Y/ABorbMzLNU3sNoK3/nPtgcVU=",         
         "path": "github.com/zeromq/goczmq",                     
         "revision": "a3998524f7fcd7fab479e485fa2ae3b02bcf6cac", 
         "revisionTime": "2017-11-11T20:18:50Z"                  
    }
    

    Local Libraries

    $ rpm -qa | grep zmq
    cppzmq-devel-4.1.6-2.fc26.x86_64
    czmq-devel-4.0.2-5.fc27.x86_64
    czmq-4.0.2-5.fc27.x86_64
    $ rpm -qa | grep zeromq
    zeromq-devel-4.1.6-2.fc26.x86_64
    zeromq-4.1.6-2.fc26.x86_64
    

    Compilers

    $ rpm -qa | grep golang
    golang-1.9.2-1.fc27.x86_64
    golang-src-1.9.2-1.fc27.noarch
    golang-bin-1.9.2-1.fc27.x86_64
    $ rpm -qa | grep gcc
    gcc-7.2.1-2.fc27.x86_64
    libgcc-7.2.1-2.fc27.x86_64
    

    Build Errors

    /usr/lib/golang/pkg/tool/linux_amd64/link: running gcc failed: exit status 1
    /tmp/go-link-960616506/000000.o: In function `_cgo_d0d31912427f_Cfunc_zsock_connect_timeout':
    github.com/zeromq/goczmq/_obj/cgo-gcc-prolog:77: undefined reference to `zsock_connect_timeout'
    /tmp/go-link-960616506/000000.o: In function `_cgo_d0d31912427f_Cfunc_zsock_heartbeat_ivl':
    github.com/zeromq/goczmq/_obj/cgo-gcc-prolog:288: undefined reference to `zsock_heartbeat_ivl'
    /tmp/go-link-960616506/000000.o: In function `_cgo_d0d31912427f_Cfunc_zsock_heartbeat_timeout':
    github.com/zeromq/goczmq/_obj/cgo-gcc-prolog:306: undefined reference to `zsock_heartbeat_timeout'
    /tmp/go-link-960616506/000000.o: In function `_cgo_d0d31912427f_Cfunc_zsock_heartbeat_ttl':
    github.com/zeromq/goczmq/_obj/cgo-gcc-prolog:324: undefined reference to `zsock_heartbeat_ttl'
    /tmp/go-link-960616506/000000.o: In function `_cgo_d0d31912427f_Cfunc_zsock_invert_matching':
    github.com/zeromq/goczmq/_obj/cgo-gcc-prolog:377: undefined reference to `zsock_invert_matching'
    /tmp/go-link-960616506/000000.o: In function `_cgo_d0d31912427f_Cfunc_zsock_multicast_maxtpdu':
    github.com/zeromq/goczmq/_obj/cgo-gcc-prolog:520: undefined reference to `zsock_multicast_maxtpdu'
    /tmp/go-link-960616506/000000.o: In function `_cgo_d0d31912427f_Cfunc_zsock_set_connect_timeout':
    github.com/zeromq/goczmq/_obj/cgo-gcc-prolog:787: undefined reference to `zsock_set_connect_timeout'
    /tmp/go-link-960616506/000000.o: In function `_cgo_d0d31912427f_Cfunc_zsock_set_heartbeat_ivl':
    github.com/zeromq/goczmq/_obj/cgo-gcc-prolog:936: undefined reference to `zsock_set_heartbeat_ivl'
    /tmp/go-link-960616506/000000.o: In function `_cgo_d0d31912427f_Cfunc_zsock_set_heartbeat_timeout':
    github.com/zeromq/goczmq/_obj/cgo-gcc-prolog:950: undefined reference to `zsock_set_heartbeat_timeout'
    /tmp/go-link-960616506/000000.o: In function `_cgo_d0d31912427f_Cfunc_zsock_set_heartbeat_ttl':
    github.com/zeromq/goczmq/_obj/cgo-gcc-prolog:964: undefined reference to `zsock_set_heartbeat_ttl'
    /tmp/go-link-960616506/000000.o: In function `_cgo_d0d31912427f_Cfunc_zsock_set_invert_matching':
    github.com/zeromq/goczmq/_obj/cgo-gcc-prolog:1005: undefined reference to `zsock_set_invert_matching'
    /tmp/go-link-960616506/000000.o: In function `_cgo_d0d31912427f_Cfunc_zsock_set_multicast_maxtpdu':
    github.com/zeromq/goczmq/_obj/cgo-gcc-prolog:1089: undefined reference to `zsock_set_multicast_maxtpdu'
    /tmp/go-link-960616506/000000.o: In function `_cgo_d0d31912427f_Cfunc_zsock_set_stream_notify':
    github.com/zeromq/goczmq/_obj/cgo-gcc-prolog:1366: undefined reference to `zsock_set_stream_notify'
    /tmp/go-link-960616506/000000.o: In function `_cgo_d0d31912427f_Cfunc_zsock_set_tcp_maxrt':
    github.com/zeromq/goczmq/_obj/cgo-gcc-prolog:1462: undefined reference to `zsock_set_tcp_maxrt'
    /tmp/go-link-960616506/000000.o: In function `_cgo_d0d31912427f_Cfunc_zsock_set_use_fd':
    github.com/zeromq/goczmq/_obj/cgo-gcc-prolog:1503: undefined reference to `zsock_set_use_fd'
    /tmp/go-link-960616506/000000.o: In function `_cgo_d0d31912427f_Cfunc_zsock_set_vmci_buffer_max_size':
    github.com/zeromq/goczmq/_obj/cgo-gcc-prolog:1517: undefined reference to `zsock_set_vmci_buffer_max_size'
    /tmp/go-link-960616506/000000.o: In function `_cgo_d0d31912427f_Cfunc_zsock_set_vmci_buffer_min_size':
    github.com/zeromq/goczmq/_obj/cgo-gcc-prolog:1531: undefined reference to `zsock_set_vmci_buffer_min_size'
    /tmp/go-link-960616506/000000.o: In function `_cgo_d0d31912427f_Cfunc_zsock_set_vmci_buffer_size':
    github.com/zeromq/goczmq/_obj/cgo-gcc-prolog:1545: undefined reference to `zsock_set_vmci_buffer_size'
    /tmp/go-link-960616506/000000.o: In function `_cgo_d0d31912427f_Cfunc_zsock_set_vmci_connect_timeout':
    github.com/zeromq/goczmq/_obj/cgo-gcc-prolog:1559: undefined reference to `zsock_set_vmci_connect_timeout'
    /tmp/go-link-960616506/000000.o: In function `_cgo_d0d31912427f_Cfunc_zsock_set_xpub_manual':
    github.com/zeromq/goczmq/_obj/cgo-gcc-prolog:1573: undefined reference to `zsock_set_xpub_manual'
    /tmp/go-link-960616506/000000.o: In function `_cgo_d0d31912427f_Cfunc_zsock_set_xpub_verboser':
    github.com/zeromq/goczmq/_obj/cgo-gcc-prolog:1615: undefined reference to `zsock_set_xpub_verboser'
    /tmp/go-link-960616506/000000.o: In function `_cgo_d0d31912427f_Cfunc_zsock_set_xpub_welcome_msg':
    github.com/zeromq/goczmq/_obj/cgo-gcc-prolog:1628: undefined reference to `zsock_set_xpub_welcome_msg'
    /tmp/go-link-960616506/000000.o: In function `_cgo_d0d31912427f_Cfunc_zsock_tcp_maxrt':
    github.com/zeromq/goczmq/_obj/cgo-gcc-prolog:1817: undefined reference to `zsock_tcp_maxrt'
    /tmp/go-link-960616506/000000.o: In function `_cgo_d0d31912427f_Cfunc_zsock_thread_safe':
    github.com/zeromq/goczmq/_obj/cgo-gcc-prolog:1835: undefined reference to `zsock_thread_safe'
    /tmp/go-link-960616506/000000.o: In function `_cgo_d0d31912427f_Cfunc_zsock_use_fd':
    github.com/zeromq/goczmq/_obj/cgo-gcc-prolog:1889: undefined reference to `zsock_use_fd'
    /tmp/go-link-960616506/000000.o: In function `_cgo_d0d31912427f_Cfunc_zsock_vmci_buffer_max_size':
    github.com/zeromq/goczmq/_obj/cgo-gcc-prolog:1907: undefined reference to `zsock_vmci_buffer_max_size'
    /tmp/go-link-960616506/000000.o: In function `_cgo_d0d31912427f_Cfunc_zsock_vmci_buffer_min_size':
    github.com/zeromq/goczmq/_obj/cgo-gcc-prolog:1925: undefined reference to `zsock_vmci_buffer_min_size'
    /tmp/go-link-960616506/000000.o: In function `_cgo_d0d31912427f_Cfunc_zsock_vmci_buffer_size':
    github.com/zeromq/goczmq/_obj/cgo-gcc-prolog:1943: undefined reference to `zsock_vmci_buffer_size'
    /tmp/go-link-960616506/000000.o: In function `_cgo_d0d31912427f_Cfunc_zsock_vmci_connect_timeout':
    github.com/zeromq/goczmq/_obj/cgo-gcc-prolog:1961: undefined reference to `zsock_vmci_connect_timeout'
    collect2: error: ld returned 1 exit status
    

    Solution

    Update documentation to note a requirement on the unreleased CZMQ 4.2.x

    Updates

    Manually create 4.2.0 builds of CZMQ and installed locally.

    $ rpm -qa | grep czmq
    czmq-4.2.0-1.fc27.x86_64
    czmq-devel-4.2.0-1.fc27.x86_64
    

    No more errors when building.

    opened by ashcrow 5
  • Cross platform builds for Windows and Linux fail from OS X build

    Cross platform builds for Windows and Linux fail from OS X build

    I'm trying to build a statically built binary to run across all the major platforms, but this isn't working with Windows or Linux (built from my OS X machine).

    Windows

    $ CGO_ENABLED=1 GOOS=windows GOARCH=amd64 go build -a -tags netgo -ldflags '-w' -o client .
    # github.com/zeromq/goczmq
    warning: unknown warning option '-Wno-pedantic-ms-format'; did you mean '-Wno-pedantic'? [-Wunknown-warning-option]
    ../../../../../zeromq/goczmq/auth.go:4:10: fatal error: 'czmq.h' file not found
    #include "czmq.h"
             ^
    1 warning and 1 error generated.
    

    Linux

    $ CGO_ENABLED=1 GOOS=linux GOARCH=amd64 go build -a -tags netgo -ldflags '-w' -o client .
    # runtime/cgo
    ld: unknown option: --build-id=none
    clang: error: linker command failed with exit code 1 (use -v to see invocation)
    

    Darwin

    $ CGO_ENABLED=1 GOOS=darwin GOARCH=amd64 go build -a -tags netgo -ldflags '-w' -o client .
    $ # built fine
    

    Next steps

    I'm going to try out the old way of doing this tomorrow (using Gimme to fetch the right versions of go), but it would cool to figure out if/where this can be addressed in goczmq to make cross platform builds work well.

    enhancement help wanted wontfix 
    opened by rgbkrk 5
  • Sometimes get

    Sometimes get "frame error" on rx/tx, but retry method call can fix it

    Sometimes call RecvMessage() return recv frame error and SendFrame() return send frame error. But just retry call fix this problem.

    Steps to reproduce: run this program (for loop is important part):

    package main
    
    import (
    	"github.com/zeromq/goczmq"
    	"log"
    	"os"
    )
    
    func main() {
    
    	rxUrl := "tcp://*:5555"
    	txUrl := "tcp://127.0.0.1:5555"
    
    	if len(os.Args) != 3 {
    		log.Println("Usage: proxy rxUrl txUrl")
    		log.Println("Using default values: proxy \"tcp://*:5555\" \"tcp://127.0.0.1:5555\"")
    	} else {
    		rxUrl = os.Args[1]
    		txUrl = os.Args[2]
    	}
    
    	router, err := goczmq.NewRouter(rxUrl)
    	if err != nil {
    		log.Fatal(err)
    	}
    	defer router.Destroy()
    
    	dealer, err := goczmq.NewDealer(txUrl)
    	if err != nil {
    		log.Fatal(err)
    	}
    	defer dealer.Destroy()
    
    	err = dealer.SendFrame([]byte("123"), goczmq.FlagNone)
    	if err != nil {
    		log.Fatal(err)
    	}
    
    	seq := 0
    	for {
    		var data [][]byte
    		seq++
    
    		for {
    			data, err = router.RecvMessage()
    			if err != nil {
    				log.Printf("rx error \"%v\" on iteration %v\n", err, seq)
    			} else {
    				break
    			}
    		}
    
    		for {
    			err = dealer.SendFrame(data[1], goczmq.FlagNone)
    			if err != nil {
    				log.Printf("tx error \"%v\" on iteration %v\n", err, seq)
    			} else {
    				break
    			}
    
    		}
    	}
    }
    

    Sample output:

    2022/06/02 16:17:18 Usage: proxy rxUrl txUrl
    2022/06/02 16:17:18 Using default values: proxy "tcp://*:5555" "tcp://127.0.0.1:5555"
    2022/06/02 16:17:18 rx error "recv frame error" on iteration 12506
    2022/06/02 16:17:19 rx error "recv frame error" on iteration 32214
    2022/06/02 16:17:19 rx error "recv frame error" on iteration 48934
    2022/06/02 16:17:19 rx error "recv frame error" on iteration 71562
    2022/06/02 16:17:20 rx error "recv frame error" on iteration 77118
    2022/06/02 16:17:25 rx error "recv frame error" on iteration 342318
    2022/06/02 16:17:25 rx error "recv frame error" on iteration 348342
    2022/06/02 16:17:25 rx error "recv frame error" on iteration 351665
    2022/06/02 16:17:26 tx error "send frame error" on iteration 365049
    2022/06/02 16:17:26 rx error "recv frame error" on iteration 377613
    2022/06/02 16:17:26 rx error "recv frame error" on iteration 393592
    2022/06/02 16:17:27 rx error "recv frame error" on iteration 414721
    2022/06/02 16:17:27 rx error "recv frame error" on iteration 424175
    ^C
    
    opened by lynxzp 1
  • Package libczmq was not found in the pkg-config search path.

    Package libczmq was not found in the pkg-config search path.

    go build -tags 'goczmq' main.go

    pkg-config --cflags -- libczmq libzmq libsodium

    Package libczmq was not found in the pkg-config search path. Perhaps you should add the directory containing `libczmq.pc' to the PKG_CONFIG_PATH environment variable No package 'libczmq' found pkg-config: exit status 1

    vim /etc/profile KG_CONFIG_PATH=/usr/local/lib/pkgconfig:/opt/code/goProjects/libsodium-stable LD_LIBRARY_PATH=/usr/local/lib

    [[email protected] czmq]# ll /usr/local/lib/pkgconfig total 12 -rw-r--r-- 1 root root 959 Apr 1 10:50 libczmq.pc -rw-r--r-- 1 root root 267 Apr 1 09:26 libsodium.pc -rw-r--r-- 1 root root 290 Apr 1 10:47 libzmq.pc

    [[email protected] czmq]# ll /usr/local/lib total 61972 -rw-r--r-- 1 root root 5394616 Apr 1 10:50 libczmq.a -rwxr-xr-x 1 root root 1011 Apr 1 10:50 libczmq.la lrwxrwxrwx 1 root root 16 Apr 1 10:50 libczmq.so -> libczmq.so.4.2.2 lrwxrwxrwx 1 root root 16 Apr 1 10:50 libczmq.so.4 -> libczmq.so.4.2.2 -rwxr-xr-x 1 root root 2387528 Apr 1 10:50 libczmq.so.4.2.2 -rw-r--r-- 1 root root 4051946 Apr 1 09:26 libsodium.a -rwxr-xr-x 1 root root 953 Apr 1 09:26 libsodium.la lrwxrwxrwx 1 root root 19 Apr 1 09:26 libsodium.so -> libsodium.so.23.3.0 lrwxrwxrwx 1 root root 19 Apr 1 09:26 libsodium.so.23 -> libsodium.so.23.3.0 -rwxr-xr-x 1 root root 2579344 Apr 1 09:26 libsodium.so.23.3.0 -rw-r--r-- 1 root root 36762758 Apr 1 10:47 libzmq.a -rwxr-xr-x 1 root root 931 Apr 1 10:47 libzmq.la lrwxrwxrwx 1 root root 15 Apr 1 10:47 libzmq.so -> libzmq.so.5.2.5 lrwxrwxrwx 1 root root 15 Apr 1 10:47 libzmq.so.5 -> libzmq.so.5.2.5 -rwxr-xr-x 1 root root 12258384 Apr 1 10:47 libzmq.so.5.2.5 drwxr-xr-x 3 root root 18 Feb 25 17:59 node_modules drwxr-xr-x 2 root root 61 Apr 1 10:50 pkgconfig drwxr-xr-x. 3 root root 27 May 21 2021 python3.6

    Where is wrong?

    opened by shiyong1989 1
  • SIGABRT on newReq() in simultaneous goroutines

    SIGABRT on newReq() in simultaneous goroutines

    I get an inconsistent, occasional SIGABRT on calling newReq(). The program opens many request lines, so my initial guess is that calling newReq from many goroutines at once is causing the crash? Here is the panic:

    web_controller: src/zsys.c:219: zsys_init: Assertion `!s_process_ctx' failed.
    SIGABRT: abort
    PC=0x7f1fcf38b03b m=6 sigcode=18446744073709551610
    
    goroutine 0 [idle]:
    runtime: unknown pc 0x7f1fcf38b03b
    stack: frame={sp:0x7f1fa5c57770, fp:0x0} stack=[0x7f1fa5457f30,0x7f1fa5c57b30)
    0x00007f1fa5c57670:  0x00000000005e5d72 <gopkg.in/zeromq/goczmq%2ev4.NewReq+0x0000000000000052>  0x0000000000000000 
    0x00007f1fa5c57680:  0x0000000000415d28 <runtime.mallocgc+0x00000000000004e8>  0x0000007800003f5f 
    0x00007f1fa5c57690:  0x0000000000000000  0x0000000000000070 
    0x00007f1fa5c576a0:  0xffffffffa5c57790  0x0000000000412740 <runtime.Caller+0x0000000000000000> 
    0x00007f1fa5c576b0:  0x0000000000000064  0x0000000000000007 
    0x00007f1fa5c576c0:  0x00007f1fa5c57740  0x0000000000459aad <runtime.funcspdelta+0x000000000000004d> 
    0x00007f1fa5c576d0:  0x0000000000000001  0x0000003100000007 
    0x00007f1fa5c576e0:  0x0000000000000000  0x00007f1f94000020 
    0x00007f1fa5c576f0:  0x00007f1f94000db0  0x000000000000004f 
    0x00007f1fa5c57700:  0x000000000000004f  0x00007f1f94000da0 
    0x00007f1fa5c57710:  0x0000000000000070  0x00007f1fcf3e3186 
    0x00007f1fa5c57720:  0x3931321fa5c57780  0xfceb9bdaa1ab0300 
    0x00007f1fa5c57730:  0x00007f1f94000db0  0x00007f1fa5c579d0 
    0x00007f1fa5c57740:  0x000000000000004e  0x000000000000004e 
    0x00007f1fa5c57750:  0x000000000000004f  0x00007f1f94000db0 
    0x00007f1fa5c57760:  0x00007f1fa5c57780  0x00007f1fcf3d3c39 
    0x00007f1fa5c57770: <0x0000000000000000  0x00007f1fcf3e2700 
    0x00007f1fa5c57780:  0x00000000fbad8000  0x00007f1f94000db0 
    0x00007f1fa5c57790:  0x00007f1f94000db0  0x00007f1f94000db0 
    0x00007f1fa5c577a0:  0x00007f1f94000db0  0x00007f1f94000dfe 
    0x00007f1fa5c577b0:  0x00007f1f94000e14  0x00007f1f94000db0 
    0x00007f1fa5c577c0:  0x00007f1f94000e14  0x0000000000000000 
    0x00007f1fa5c577d0:  0x0000000000000000  0x0000000000000000 
    0x00007f1fa5c577e0:  0x0000000000000000  0x0000000000000000 
    0x00007f1fa5c577f0:  0xfffffffe7fffffff  0xffffffffffffffff 
    0x00007f1fa5c57800:  0xffffffffffffffff  0xffffffffffffffff 
    0x00007f1fa5c57810:  0xffffffffffffffff  0xffffffffffffffff 
    0x00007f1fa5c57820:  0xffffffffffffffff  0xffffffffffffffff 
    0x00007f1fa5c57830:  0xffffffffffffffff  0xffffffffffffffff 
    0x00007f1fa5c57840:  0xffffffffffffffff  0xffffffffffffffff 
    0x00007f1fa5c57850:  0xffffffffffffffff  0xffffffffffffffff 
    0x00007f1fa5c57860:  0xffffffffffffffff  0xffffffffffffffff 
    runtime: unknown pc 0x7f1fcf38b03b
    stack: frame={sp:0x7f1fa5c57770, fp:0x0} stack=[0x7f1fa5457f30,0x7f1fa5c57b30)
    0x00007f1fa5c57670:  0x00000000005e5d72 <gopkg.in/zeromq/goczmq%2ev4.NewReq+0x0000000000000052>  0x0000000000000000 
    0x00007f1fa5c57680:  0x0000000000415d28 <runtime.mallocgc+0x00000000000004e8>  0x0000007800003f5f 
    0x00007f1fa5c57690:  0x0000000000000000  0x0000000000000070 
    0x00007f1fa5c576a0:  0xffffffffa5c57790  0x0000000000412740 <runtime.Caller+0x0000000000000000> 
    0x00007f1fa5c576b0:  0x0000000000000064  0x0000000000000007 
    0x00007f1fa5c576c0:  0x00007f1fa5c57740  0x0000000000459aad <runtime.funcspdelta+0x000000000000004d> 
    0x00007f1fa5c576d0:  0x0000000000000001  0x0000003100000007 
    0x00007f1fa5c576e0:  0x0000000000000000  0x00007f1f94000020 
    0x00007f1fa5c576f0:  0x00007f1f94000db0  0x000000000000004f 
    0x00007f1fa5c57700:  0x000000000000004f  0x00007f1f94000da0 
    0x00007f1fa5c57710:  0x0000000000000070  0x00007f1fcf3e3186 
    0x00007f1fa5c57720:  0x3931321fa5c57780  0xfceb9bdaa1ab0300 
    0x00007f1fa5c57730:  0x00007f1f94000db0  0x00007f1fa5c579d0 
    0x00007f1fa5c57740:  0x000000000000004e  0x000000000000004e 
    0x00007f1fa5c57750:  0x000000000000004f  0x00007f1f94000db0 
    0x00007f1fa5c57760:  0x00007f1fa5c57780  0x00007f1fcf3d3c39 
    0x00007f1fa5c57770: <0x0000000000000000  0x00007f1fcf3e2700 
    0x00007f1fa5c57780:  0x00000000fbad8000  0x00007f1f94000db0 
    0x00007f1fa5c57790:  0x00007f1f94000db0  0x00007f1f94000db0 
    0x00007f1fa5c577a0:  0x00007f1f94000db0  0x00007f1f94000dfe 
    0x00007f1fa5c577b0:  0x00007f1f94000e14  0x00007f1f94000db0 
    0x00007f1fa5c577c0:  0x00007f1f94000e14  0x0000000000000000 
    0x00007f1fa5c577d0:  0x0000000000000000  0x0000000000000000 
    0x00007f1fa5c577e0:  0x0000000000000000  0x0000000000000000 
    0x00007f1fa5c577f0:  0xfffffffe7fffffff  0xffffffffffffffff 
    0x00007f1fa5c57800:  0xffffffffffffffff  0xffffffffffffffff 
    0x00007f1fa5c57810:  0xffffffffffffffff  0xffffffffffffffff 
    0x00007f1fa5c57820:  0xffffffffffffffff  0xffffffffffffffff 
    0x00007f1fa5c57830:  0xffffffffffffffff  0xffffffffffffffff 
    0x00007f1fa5c57840:  0xffffffffffffffff  0xffffffffffffffff 
    0x00007f1fa5c57850:  0xffffffffffffffff  0xffffffffffffffff 
    0x00007f1fa5c57860:  0xffffffffffffffff  0xffffffffffffffff 
    
    goroutine 10 [syscall]:
    runtime.cgocall(0x7664f0, 0xc00020ebf0)
            /usr/local/go/src/runtime/cgocall.go:156 +0x5c fp=0xc00020ebc8 sp=0xc00020eb90 pc=0x40c59c
    gopkg.in/zeromq/goczmq%2ev4._Cfunc_zsock_new_checked(0x3, 0x7f1f94000ce0, 0xbd)
            _cgo_gotypes.go:1086 +0x4d fp=0xc00020ebf0 sp=0xc00020ebc8 pc=0x5e53cd
    gopkg.in/zeromq/goczmq%2ev4.NewSock(0x3)
            /opt/go/pkg/mod/gopkg.in/zeromq/[email protected]/sock.go:85 +0x196 fp=0xc00020ec68 sp=0xc00020ebf0 pc=0x5e57d6
    gopkg.in/zeromq/goczmq%2ev4.NewReq({0xc0002a8000, 0x15})
            /opt/go/pkg/mod/gopkg.in/zeromq/[email protected]/sock.go:189 +0x28 fp=0xc00020eca0 sp=0xc00020ec68 pc=0x5e5d48
    main.bindReq({0x82a945, 0xa}, {0x82c068, 0xe})
            /opt/app/req.go:45 +0x125 fp=0xc00020ed58 sp=0xc00020eca0 pc=0x763a05
    ...
    runtime.goexit()
            /usr/local/go/src/runtime/asm_amd64.s:1581 +0x1 fp=0xc00020efe8 sp=0xc00020efe0 pc=0x46bfe1
    created by main.main
            /opt/app/main.go:36 +0x65
    
    
    goroutine 11 [runnable]:
    gopkg.in/zeromq/goczmq%2ev4.(*Sock).Attach.func1(0x7f1f98006230)
            /opt/go/pkg/mod/gopkg.in/zeromq/[email protected]/sock.go:149 +0x2c
    gopkg.in/zeromq/goczmq%2ev4.(*Sock).Attach(0x3, {0xc000220000, 0x14}, 0x0)
            /opt/go/pkg/mod/gopkg.in/zeromq/[email protected]/sock.go:149 +0x53
    gopkg.in/zeromq/goczmq%2ev4.NewReq({0xc000220000, 0x14})
            /opt/go/pkg/mod/gopkg.in/zeromq/[email protected]/sock.go:190 +0x3e
    main.bindReq({0x82cad7, 0x10}, {0x82ea16, 0x14})
            /opt/app/req.go:45 +0x125
    ...
    created by main.main
            /opt/app/main.go:37 +0x73
    
    goroutine 12 [runnable]:
    gopkg.in/zeromq/goczmq%2ev4._Cfunc_zsock_new_checked(0x3, 0xc2dac0, 0xbd)
            _cgo_gotypes.go:1086 +0x4d
    gopkg.in/zeromq/goczmq%2ev4.NewSock(0x3)
            /opt/go/pkg/mod/gopkg.in/zeromq/[email protected]/sock.go:85 +0x196
    gopkg.in/zeromq/goczmq%2ev4.NewReq({0xc000028300, 0x14})
            /opt/go/pkg/mod/gopkg.in/zeromq/[email protected]/sock.go:189 +0x28
    main.bindReq({0x82f973, 0x16}, {0x8318f4, 0x1a})
            /opt/app/req.go:45 +0x125
    ...
    created by main.main
            /opt/app/main.go:38 +0x85
    
    rax    0x0
    rbx    0x7f1fa5c58700
    rcx    0x7f1fcf38b03b
    rdx    0x0
    rdi    0x2
    rsi    0x7f1fa5c57770
    rbp    0x7f1fcf500588
    rsp    0x7f1fa5c57770
    r8     0x0
    r9     0x7f1fa5c57770
    r10    0x8
    r11    0x246
    r12    0x7f1fcf5b9655
    r13    0xdb
    r14    0x7f1fcf5b984f
    r15    0x7f1fa7e02100
    rip    0x7f1fcf38b03b
    rflags 0x246
    cs     0x33
    fs     0x0
    gs     0x0
    
    opened by bjubes 0
  • Support for zmq_device

    Support for zmq_device

    Was trying a goczmq based implementation of the mtserver example in https://zguide.zeromq.org/docs/chapter2/ and found that there's currently no wrapper around zmq_device.

    opened by TropicalPenguin 0
  • why i send once, but receive twice

    why i send once, but receive twice

    server

    package main
    
    import (
    	"fmt"
    	"math/rand"
    	"time"
    
    	czmq "github.com/zeromq/goczmq"
    )
    
    func main() {
    	pubEndpoint := "tcp://*:5556"
    	pubSock, err := czmq.NewPub(pubEndpoint)
    	if err != nil {
    		panic(err)
    	}
    
    	defer pubSock.Destroy()
    	pubSock.Bind(pubEndpoint)
    
    	for {
    		zipcode := rand.Intn(100000)
    		temperature := rand.Intn(215) - 85
    		relHumidity := rand.Intn(50) + 10
    
    		msg := fmt.Sprintf("%d %d %d", zipcode, temperature, relHumidity)
    		err := pubSock.SendFrame([]byte(msg), 0)
    		if err != nil {
    			panic(err)
    		}
    		fmt.Println("send", msg)
    		time.Sleep(time.Second * 10)
    	}
    }
    

    client

    package main
    
    import (
    	"fmt"
    	"strconv"
    	"strings"
    
    	czmq "github.com/zeromq/goczmq"
    )
    
    func main() {
    
    	pubEndpoint := "tcp://127.0.0.1:5556"
    	filter := ""
    
    	subSock, err := czmq.NewSub(pubEndpoint, filter)
    	if err != nil {
    		panic(err)
    	}
    
    	defer subSock.Destroy()
    
    	fmt.Printf("Collecting updates from weather server for %s…\n", filter)
    	subSock.Connect(pubEndpoint)
    
    	for i := 0; i < 100; i++ {
    		msg, _, err := subSock.RecvFrame()
    		if err != nil {
    			panic(err)
    		}
    		fmt.Println("recv msg", i, string(msg))
    		weatherData := strings.Split(string(msg), " ")
    		temperature, err := strconv.ParseInt(weatherData[1], 10, 64)
    		fmt.Println("recv temperature", temperature)
    	}
    
    }
    

    server output

    send 5384 2 27
    send 86137 -34 54
    send 97726 52 41
    send 12079 46 30
    send 30493 126 29
    send 98981 67 35
    send 44885 105 47
    send 73749 88 28
    send 4384 53 34
    send 64547 92 42
    send 3616 -11 50
    send 25786 -14 36
    

    client output

    recv msg 0 54425 55 16
    recv temperature 55
    recv msg 1 54425 55 16
    recv temperature 55
    recv msg 2 3300 -31 21
    recv temperature -31
    recv msg 3 3300 -31 21
    recv temperature -31
    recv msg 4 28162 64 38
    recv temperature 64
    recv msg 5 28162 64 38
    recv temperature 64
    
    opened by skmygdrs 1
  • Socket not removed from Poller during `Remove()`

    Socket not removed from Poller during `Remove()`

    Poller.Remove() doesn't actually remove the given socket from the underlying czmq poller, it just removes it from the slice of golang objects wrapping sockets. While I can't explain the exact reason behind it, this is causing weird behavior when sockets are removed from the poller (at the golang level), the sockets are destroyed, and then new sockets are added to the poller. In these cases the poller never notices new reads pending on the new sockets

    opened by ashmrtn 0
Releases(v4.2.0)
  • v4.2.0(Jun 22, 2019)

    The deprecated Sock option API has now been removed in favor of the new functional args API. Example:

    sock := NewSock(Dealer)
    defer sock.Destroy()
    sock.SetOption(SockSetHeartbeatIvl(2000))
    
    Source code(tar.gz)
    Source code(zip)
  • v4.1.0(Oct 26, 2017)

    We are about to refactor the socket option API to use functional arguments to improve the overall user experience of the API. 4.1.0 is the last release to be compatible with the original socket option API.

    Source code(tar.gz)
    Source code(zip)
  • v4.0.2(Dec 23, 2016)

    This is the final release of GoCZMQ that will be backwards compatible with CZMQ 4.0. New releases, as well as the GoCZMQ master branch moving forward, will require CZMQ 4.2/

    Source code(tar.gz)
    Source code(zip)
  • v4.0(Nov 16, 2016)

Owner
The ZeroMQ project
The ZeroMQ project
Golang AMQP wrapper for RabbitMQ with better API

go-rabbitmq Golang AMQP wrapper for RabbitMQ with better API Table of Contents Background Features Usage Installation Connect to RabbitMQ Declare Queu

Hadi Hidayat Hammurabi 7 Jun 28, 2022
High abstraction wrapper for Golang Rabbit MQ Client

GRMQ Go Rabbit MQ What are the typical use-cases of RabbitMQ broker ? We create

null 5 Jan 12, 2022
A tiny wrapper around NSQ topic and channel :rocket:

Event Bus NSQ A tiny wrapper around go-nsq topic and channel. Protect nsq calls with gobreaker. Installation go get -u github.com/rafaeljesus/nsq-even

Rafael Jesus 74 Jul 20, 2022
A tiny wrapper over amqp exchanges and queues 🚌 ✨

Rabbus ?? ✨ A tiny wrapper over amqp exchanges and queues. In memory retries with exponential backoff for sending messages. Protect producer calls wit

Rafael Jesus 93 May 29, 2022
A wrapper of streadway/amqp that provides reconnection logic and sane defaults

go-rabbitmq Wrapper of streadway/amqp that provides reconnection logic and sane defaults. Hit the project with a star if you find it useful ⭐ Supporte

Lane Wagner 356 Jul 30, 2022
graylog-golang is a full implementation for sending messages in GELF (Graylog Extended Log Format) from Go (Golang) to Graylog

graylog-golang is a full implementation for sending messages in GELF (Graylog Extended Log Format) from Go (Golang) to Graylog

Robert Kowalski 78 Aug 1, 2022
Confluent's Apache Kafka Golang client

Confluent's Golang Client for Apache KafkaTM confluent-kafka-go is Confluent's Golang client for Apache Kafka and the Confluent Platform. Features: Hi

Confluent Inc. 3.4k Aug 5, 2022
socket.io library for golang, a realtime application framework.

go-socket.io go-socket.io is library an implementation of Socket.IO in Golang, which is a realtime application framework. Current this library support

Googol Lee 4.7k Jul 31, 2022
golang client library to Viessmann Vitotrol web service

Package go-vitotrol provides access to the Viessmann™ Vitotrol™ cloud API for controlling/monitoring boilers. See https://www.viessmann.com/app_vitoda

Maxime Soulé 18 Jun 23, 2022
golang long polling library. Makes web pub-sub easy via HTTP long-poll server :smiley: :coffee: :computer:

golongpoll Golang long polling library. Makes web pub-sub easy via an HTTP long-poll server. New in v1.1 Deprecated CreateManager and CreateCustomMana

J Cuga 605 Aug 6, 2022
Golang push server cluster

gopush-cluster gopush-cluster is a go push server cluster. Features light weight high performance pure golang implementation message expired offline m

Terry.Mao 2k Jul 26, 2022
A push notification server written in Go (Golang).

gorush A push notification micro server using Gin framework written in Go (Golang) and see the demo app. Contents gorush Contents Support Platform Fea

Bo-Yi Wu 6.5k Aug 10, 2022
websocket based messaging server written in golang

Guble Messaging Server Guble is a simple user-facing messaging and data replication server written in Go. Overview Guble is in an early state (release

Sebastian Mancke 152 Jul 19, 2022
🐇 Easy to use socket lib for Golang

Hare Sockets ?? Hare is a user-friendly lib for sockets in Golang. You can send and listen to TCP connections with a few lines of code. Contents Insta

Leonardo Lima 48 Jul 2, 2022
mangos is a pure Golang implementation of nanomsg's "Scalablilty Protocols"

mangos Mangos™ is an implementation in pure Go of the SP (“Scalability Protocols”) messaging system. These are colloquially known as a “nanomsg”. ❗ Th

nanomsg 534 Aug 6, 2022
Golang client for NATS, the cloud native messaging system.

NATS - Go Client A Go client for the NATS messaging system. Installation # Go client go get github.com/nats-io/nats.go/ # Server go get github.com/na

NATS - The Cloud Native Messaging System 4.1k Aug 9, 2022
Go (golang) bindings for the 0mq (zmq, zeromq) C API

NOTE: These gozmq bindings are in maintenance mode. Only critical bugs will be fixed. Henceforth I would suggest using @pebbe's actively maintained bi

Alec Thomas 469 Jul 24, 2022
A user friendly RabbitMQ library written in Golang.

TurboCookedRabbit A user friendly RabbitMQ library written in Golang to help use streadway/amqp. Based on my work found at CookedRabbit. Work Recently

Tristan (HouseCat) Hyams 102 Jul 18, 2022
Simple synchronous event pub-sub package for Golang

event-go Simple synchronous event pub-sub package for Golang This is a Go language package for publishing/subscribing domain events. This is useful to

itchyny 19 Jun 16, 2022