You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Can we get some FsNetMQ exmaples? Or do they already exist somewhere? #1
by the way, there are several typos in the example code.
for instance
use router = Socket.router ()
router.bind socket "tcp://*:6566"
should be
use router = Socket.router ()
Socket.bind router "tcp://*:6566"
and use subscriber = Socker.sub ()
should be
use subscriber = Socket.sub ()
Also, I tried to put together a working version of the NetMQ router-dealer example so that you could include it as an official example, but I am having difficulty porting it. Here is a snippet of the attempt
[1 .. 3]
|> List.iter(fun i ->
use client = Socket.dealer()
match client with
|Socket.Socket s ->
s.Options.Identity = Encoding.Unicode.GetBytes(sprintf "Client %i" i)
|> ignore
let dealerObservable =
Poller.addSocket poller client
|> Observable.map (fun socket -> socket |> Socket.Socket |> Frame.recv)
|> Observable.subscribe (fun msg ->
()//not sure how to read the frames with this
)
async{
let rec infiniteLoop () =
sprintf "This is client %i" i
|> (fun s -> Encoding.Unicode.GetBytes(s))
|> Frame.send client
Thread.Sleep(delay)
infiniteLoop()
infiniteLoop()
} |> Async.Start
)
Is any of this the recommended approach?
Edit: this is how I would do it using regular NetMQ from F#, which seems to work.
let delay = 3000
use poller = new NetMQPoller()
[1..3]
|> List.iter(fun i ->
async{
use client = new DealerSocket()
let clientName = sprintf "Client %i" i
client.Options.Identity = Encoding.Unicode.GetBytes(clientName) |> ignore
client.Connect("tcp://127.0.0.1:5556");
client.ReceiveReady.Add (fun eventArgs ->
printfn "Received a message from the server"
printfn "%s" (eventArgs.Socket.ReceiveFrameString())
)
poller.Add(client)
let rec infiniteLoop() =
let messageToServer = new NetMQMessage()
messageToServer.AppendEmptyFrame()
messageToServer.Append(sprintf "Hello this is %s" clientName)
printfn("======================================")
printfn(" OUTGOING MESSAGE TO SERVER ")
printfn("======================================")
client.SendMultipartMessage(messageToServer)
Thread.Sleep(delay)
printfn "Sleep over"
infiniteLoop()
infiniteLoop()
}
|> Async.Start
)
poller.RunAsync()
I also have this problem with the polling example. Here is the Ionide error tooltip highlighting Frame.recv:
Type mismatch. Expecting a
'NetMQ.NetMQSocket -> 'a'
but given a
'Socket.T -> byte array * bool'
The type 'NetMQ.NetMQSocket' does not match the type 'Socket.T'F# Compiler[1](https://docs.microsoft.com/en-us/dotnet/fsharp/language-reference/compiler-messages/fs0001)
val recv:
T
-> byte array * bool
Full name: FsNetMQ.Frame.recv
Assembly: FsNetMQ
Activity
somdoron commentedon May 8, 2018
I will try to write some today
somdoron commentedon May 8, 2018
Just added some examples.
Will try to add some more during the week. Let me know if you need more help
travis-leith commentedon May 8, 2018
got it thanks!
travis-leith commentedon May 9, 2018
by the way, there are several typos in the example code.
for instance
should be
and
use subscriber = Socker.sub ()should be
use subscriber = Socket.sub ()Also, I tried to put together a working version of the NetMQ router-dealer example so that you could include it as an official example, but I am having difficulty porting it. Here is a snippet of the attempt
Is any of this the recommended approach?
Edit: this is how I would do it using regular NetMQ from F#, which seems to work.
poroburu commentedon May 1, 2023
I also have this problem with the polling example. Here is the Ionide error tooltip highlighting
Frame.recv:poroburu commentedon May 1, 2023
For those who are going through the zguide with fsx scripts.
#r "nuget:FsNetMQ,0.5.0-pre"Works better now, oops 😹 👍