Skip to content

Basic Server Client Example not Working. #62

@VishalMCF

Description

@VishalMCF

Server main.go

`package main

import (
evbus "github.com/asaskevich/EventBus"
)

func main() {
server := evbus.NewServer(":8090", "/server_bus", evbus.New())
server.Start()
// ...
server.EventBus().Publish("main:calculator", 4, 6)
}`

Client main.go

`
package main

import (
"fmt"
evbus "github.com/asaskevich/EventBus"
)

func calculator(a int, b int) {
fmt.Printf("%d\n", a+b)
}

func main() {
client := evbus.NewClient(":8089", "/_server_bus", evbus.New())
client.Start()
client.Subscribe("main:calculator", calculator, ":8090", "/server_bus")
}
`
After running the server code I try to run the client and I get this in the console ->
Server not found - runtime error: invalid memory address or nil pointer dereference

Can someone please tell me what I am doing wrong?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions