Remote Get/Query with pattern matching is buggy.
Closed this issue · 2 comments
albertolluch commented
Commands like s.Get(&x)
on a remote space s
seem to incorrectly block even if there are matching tuples in s
.
Minimal example:
Server source:
package main
import (
"fmt"
. "github.com/pspaces/gospace"
)
func main() {
fmt.Printf("Creating space...\n")
space := NewSpace("tcp://localhost/space")
space.Query("done")
}
Client source:
package main
import (
"fmt"
. "github.com/pspaces/gospace"
)
func main() {
fmt.Printf("Connecting to remote space...\n")
space := NewRemoteSpace("tcp://localhost/space")
fmt.Printf("Connection established.\n")
var x int
x = 0
space.Put(1)
//space.Get(1) // this succeeds
space.Get(&x) // this fails and blocks forever
fmt.Printf("x is %d\n", x)
fmt.Printf("Done testing.\n")
}
Deleted user commented
This is not a bug.
This is how TCP protocol works: only a single application can be bound to a port. The UDP protocol does not have this issue for example.
By default, both the client and server will try to bind to port 31415 as specified by the pSpace specification.
This can be circumvented in two ways by:
- Using containers or virtualisation, and executing client and server on different containers (LXC, Docker, etc.) or through virtual machines (VirtualBox, KVM, Xen, etc.).
- Creating an additional virtual interface on the host machine with an new IP address for which
NewRemoteSpace
will use instead oflocalhost
.
albertolluch commented
I see the problem. Let's discuss this when you start implementing repositories and gates.