I created a process in the RFID manager. In that process, i have a simulated device associated to a provider and pointing to a traslator. When the translator tries to send a tag to the provider, I get the following error in the provider's log: Received unhandled exception Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host.

This is How i run devicesimulator (cmd):

"C:\BizTalkServer2013_Developer\RFID_x64\Microsoft BizTalk RFID\bin\devicesimulator.exe" -c -f TutorialDeviceSimulatorConfig.xml*

Here is TutorialDeviceSimulatorConfig.xml:

<?xml version="1.0" encoding="utf-8" ?>
<profile>
<section name="NumberOfDevices">
    <entry name="DeviceCount">1</entry>
</section>

<section name="DeviceInformation_1">
<entry name="DeviceName">TutorialDevice3</entry>
<entry name="ConnectionType">TCPIP</entry>
<entry name="IpAddress">127.0.0.1</entry>
<entry name="PortNumber">7891</entry>
<entry name="ProviderId">TutorialProvider</entry>
<entry name="NotificationDataFile">TutorialDeviceNotificationConfig.xml</entry>
<entry name="DeviceTranslatorAssemblyPath">TutorialDeviceTranslator.dll</entry>
<entry name="DeviceTranslatorConfigFile"></entry>
</section>
</profile>

Here is TutorialDeviceNotificationConfig.xml:

<?xml version="1.0" encoding="utf-8" ?>
<profile>
<section name="Notification">
<entry name="TimePeriod">10000</entry>
<entry name="Distribution">EXPONENTIAL</entry>
<entry name="NotificationErrorRate">0</entry>
<entry name="WaitAfterNotification">1000</entry>
   <entry name="InitialDelay">100</entry>
   <entry name="Duplicate_Elimination_Time">0</entry>
   <entry name="InfiniteNotification">FALSE</entry>
   <entry name="ContinuousDataSection">0</entry>
   <entry name="DiscreteDataSection">1</entry>
</section>
<section name="Discrete Data Section 1"> 
    <entry name="NoOfData">1</entry> 
    <entry name="TagId">1234</entry>
    <entry name="TagData">1234</entry>
    <entry name="TagType">1</entry>
    <entry name="TagSource">Antenna1</entry>
</section>
</profile>

Here is the receive method of the provider (this method is running on a thread):

private void receive()
        {
            //reset the receive event, which is set when the data is received
            receiveEvent = new AutoResetEvent(false);
            //using asynchronous receive to not to block the thread
            AsyncCallback callback = new AsyncCallback(asyncReceive);
            while (true)
            {
                //int byteCount = netStrm.Read(bytes, 0, bytes.Length);
                logger.Info("MyPhysicalDeviceProxy: in receive() method");
                if (netStrm == null)
                    logger.Info("MyPhysicalDeviceProxy: netStrm is null");
                //begin reading
                logger.Info("We are reading!!!");
                IAsyncResult result = netStrm.BeginRead(bytes, 0, bytes.Length, callback, null);
                //wait for the receive event to be set
                int eventIndex = WaitHandle.WaitAny(new WaitHandle[1] { receiveEvent }, 300000, false);
                logger.Info("The event index is " + eventIndex);
                if (0 == eventIndex)
                {
                    //finish reading
                    int bytesRead = netStrm.EndRead(result);
                    logger.Info("bytesRead = " + bytesRead);
                    if (bytesRead > 0)
                    {
                        System.Text.ASCIIEncoding enc = new System.Text.ASCIIEncoding();
                        //get the xml string from the bytes
                        string str = enc.GetString(bytes);
                        str.Trim();
                        logger.Info("Here is the XML String provider got from device");
                        logger.Info(str);
                        XmlDocument doc = new XmlDocument();
                        doc.LoadXml(str);
                        //get all the needed information
                        XmlNode notificationDataNode = doc.FirstChild;
                        XmlNode tagIDNode = notificationDataNode.FirstChild;
                        string tagID = tagIDNode.InnerText;
                        XmlNode vendorDataNode = notificationDataNode.LastChild;
                        XmlNode itemIDNode = vendorDataNode.FirstChild;
                        string ItemID = itemIDNode.InnerText;
                        XmlNode poNumberNode = vendorDataNode.LastChild;
                        string PONumber = poNumberNode.InnerText;
                        //call a private method with the data to raise an event
                        handleTagReadEvent(HexUtilities.HexDecode(tagID), ItemID, PONumber, "some location", DateTime.Now);
                    }
                }
            }
        }

    private void asyncReceive(IAsyncResult result)
    {
        logger.Info("MyPhysicalDeviceProxy: In asyncReceive method");
        receiveEvent.Set();
    }

Additional info: i am doing Microsoft RFID Tutorials - Order Fulfillment

Related posts

Recent Viewed