Question Corentin Blondeau · Dec 17, 2024

UDP Adapter not working

Hello
I am trying to work with UDP Connection/Adapter and I get this error.

ERREUR #5002: Erreur Cache: <WRITE>zSend+5^EnsLib.UDP.Common.1

 Here is the method
 

Class TEMPLATE.BO.UDPSend Extends Ens.BusinessOperation
{

Parameter ADAPTER = "EnsLib.UDP.OutboundAdapter";

Property Adapter As EnsLib.UDP.OutboundAdapter;

Method SendData(pInput As Ens.Request, Output pOutput As Ens.Response) As %Status
{
    Try {
        Set status=$$$OK
        Set pOutput=##class(Ens.Response).%New()
        
        Set stream = ##class(%Stream.GlobalCharacter).%New()
        Do stream.Write("This is some text")
        $$$LOGINFO(stream.Read())
        Do stream.Rewind()

        Set status = ..Adapter.SendStream(stream)
    }
    Catch exception {
        Set status=exception.AsStatus()
    }    
    Return status
}

XData MessageMap
{
<MapItems>
<MapItem MessageType="Ens.Request">
<Method>SendData</Method>
</MapItem>
</MapItems>
}

}

I have tried with ##class(%Net.UDP).%New() and it is working.
Does anyone have an idea of why it is not working or some example of a functionnal method, please ?
Thanks in advance
Corentin
PS : For those who don't want explore the code to find the line where it generate an error : 

zSend(pDevice="",pBuffer) public { Set:'($data(pBuffer)#2) pBuffer=""
    Set tStatus = 1
    Try {
        Do pBuffer.Rewind()
        Use pDevice Do pBuffer.OutputToDevice()
        Use pDevice Write !
    }
    Catch eSend {
        Set tStatus = eSend.AsStatus()
    }
    Quit tStatus }
Product version: Ensemble 2018.1
$ZV: Cache for Windows (x86-64) 2018.1.4 (Build 505_1U) Thu May 28 2020 10:01:40 EDT

Comments

PPS : In order to test it, we can execute the following code in the terminal
 

Set sobj = ##class(%Net.UDP).%New(3001,"127.0.0.1")
zwrite sobj.Recv()
0
Corentin Blondeau · Jan 13

Update :
I have created a ticket to WRC. Indeed, there is a bug, the adapter is not working.
We have to use the ##class(%Net.UDP).%New()
Corentin

0