Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

Unable to connect multiple publishers in NI data socket application

I am using Measurement Studio 8.0.1 with C# and visual studio 2005. I have a NI Data Socket application where I would like multiple data publishers to write data to the same URL. I have set up data socket writers in each appliction. I have set the Mode in each to "Write" and I am using the dstp protocol. In each application, when I want to write data to the URL, I call Connect(), set the data value, call Update(), then call Disconnect(). In one application, which is a windows forms appliction, I have no problem doing this. However, the other application is a windows service and is supposed to write to the URL after a timer goes off. When the timer goes off, I get the message from the data socket

'LastMessage = "Error: Can't connect to data item, another write connection exists. '

I am absolutely certain that the Windows forms app called "Disconnect" at least 20 seconds before the timer expires and the windows service tries to write to the data socket.

Am I missing something? Is there some setting somewhere that needs to be set for multiple publisher scenarios to work? Are there code samples for a multiple publisher scenario? What are the recommended guidelines for multiple publisher scenarios?

Thanks in advance!
Best Regards,
Matthew

0 Kudos
Message 1 of 7
(4,174 Views)
Matthew,

Two fixes,
  • Make one DataSocket connection set to Publish to the data item. You can successfully make all other connections as Subscriber only.
  • Set up the data item as a Predefined Data Item in the DataSocket Server Manager. In the manager, you can create the item, set its properties, and set Allow Multiple Writers to True. Save these settings and if necessary, restart DataSocket Server for the settings to take effect.
Also see here and here.
Test Engineer - CTA
0 Kudos
Message 2 of 7
(4,158 Views)
Hi Jon,

Thanks for your reply.

I've done what you suggested. Each time I attempt to write call "Update" on the second data socket writing the parameter, the LastMessage field for that data socket reads "Write Ack: XXX" where XXX is a number that varies. I assume that the data socket was successful in writing the parameter.

However, the "DataUpdated" event does not fire for any data sockets that are reading the parameter.

Any suggestions?

Best Regards,
Matthew

0 Kudos
Message 3 of 7
(4,132 Views)
Hi Matthew,

What AccessMode and ReadMode are you using?
Test Engineer - CTA
0 Kudos
Message 4 of 7
(4,129 Views)
Hi Jon,

I'm using ReadAutoUpdate and WriteAutoUpdate.

Best Regards,
Matthew
0 Kudos
Message 5 of 7
(4,124 Views)
Matthew,

I would try switching to Write and Read while you are troubleshooting the connection issue.

Are you using dstp write to the url? And is this still only occurring with the service or are both publishers not having the event fire?
Test Engineer - CTA
0 Kudos
Message 6 of 7
(4,118 Views)
Yes, I am using dstp to write to the url, and yes, it still only occurs when the service writes the value.

Note (not to confuse the issue) that I did switch access modes to read on the sockets that read and write on the sockets that write. Now when I write the value from the UI, the data updated event no longer fires in the UI, but it does fire in the service, whereas when I was writing the value from the UI it fired in both the UI and the Service when when the write mode was set to writeautoupdate.

Thanks.

Best Regards,
Matthew

0 Kudos
Message 7 of 7
(4,114 Views)