Socket Client

Discussion in 'CRM / Helpdesk / App Integration' started by linking13, Sep 13, 2012.

Thread Status:
Not open for further replies.
  1. linking13

    Joined:
    Nov 14, 2008
    Messages:
    42
    Likes Received:
    0
    I'm trying to made a connection with a device that change the relay state. The device talk via UDP (port 2424) and if I try to read the status with "Wait for response from server" checked I'll see the correct response returnd, but if I add every compoent that follow the Socket client the VAD goes in error with error.badfetch. There is some trick about the UDP connection that I don't know?

    Second thing: the device accept ascii charcter incluse the null (ex. to swith off the realy the string shoud be 'A\0B\0C\0 where \0 is the null character) but if I'll check with WireShark the string sent I notice that only the first charactar ('A') is sent. There is a way to manibulate or send ascii code without using external program\function?
     
  2. VAD_Support

    VAD_Support Active Member

    Joined:
    Aug 6, 2009
    Messages:
    690
    Likes Received:
    0
    Hi,

    In order to send null characters as part of your message, you will have to create a DLL and execute it from an external code execution component. This is because VoiceXML variables are javascript variables, and javascript strings are truncated on null chars. If you create the code into a .NET DLL, you can use nulls as part of the string, and send them by the socket.

    The error.badfetch problem could be caused if the UDP peer takes too long to respond. The Socket client component is executed into an ASPX page (into the 3CX web server), so if it is configured to wait for the reponse from the UDP peer, then it could take too long to return the page results and then the client throws a badfetch error. Try to make the server a bit faster to respond. If the server is out of your control, you may configure the client to wait more time. To do this, you will have to manually change the Main.vxml file after each build. Open the file, look for the opening <form> element, and add the following just after it (and before the <block> element):
    <property name="fetchtimeout" value="10s"/>
    That value will make the client wait for 10 seconds. if you need more time, just update the value of the property.

    Hope the information helps.
     
  3. linking13

    Joined:
    Nov 14, 2008
    Messages:
    42
    Likes Received:
    0
    I'm back on this project and if a made the change as you suggested the error is the same.

    As you can notice form the log the response is correct (was correct without the manual parameter too)

    END_EXECUTION: Main.flow - - MF
    END_EXECUTION: Main.flow - conditionalComponent1 - MF
    END_EXECUTION: Main.flow - conditionalComponentBranch1 - MF
    END_EXECUTION: Main.flow - promptPlaybackComponent1 - MF
    VARIABLE_CHANGED: Main_socketClientComponent1_Response=A B`C
    END_EXECUTION: Main.flow - socketClientComponent1 - MF
    VARIABLE_CHANGED: project$_CurrentErrorDescription$=
    VARIABLE_CHANGED: project$_CurrentErrorName$=error.badfetch
    END_EXECUTION: Main.flow - - EH
    END_EXECUTION: Main.flow - errorHandlerContainer1 - EH

    The response in binary is this 41 00 42 60 43 00

    The error could be the 00 value ASCII? There is a way to accept this value?
     
  4. edossantos

    edossantos Support Team
    Staff Member 3CX Support

    Joined:
    Jun 27, 2007
    Messages:
    1,080
    Likes Received:
    77
    Hi there,

    As explained before, in order to send the null character as part of the message via the socket, you will need to do it from a DLL and call that DLL from an External Code Execution component. This is because nulls are treated as end of string characters by javascript, so you can't send from the Socket Client component.

    Can you try creating the DLL and connect the socket from there?

    Kind regards.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  5. linking13

    Joined:
    Nov 14, 2008
    Messages:
    42
    Likes Received:
    0
    Ops, I'm sorry. I haven't read well your previous reply...

    I can try with a DLL for the moment but there is no way to add a flag in the component to transform the reply in binary? I think that a there are many application that can use the null character in socket client and this option may transform the VAD more indipendent on third party component...
     
  6. edossantos

    edossantos Support Team
    Staff Member 3CX Support

    Joined:
    Jun 27, 2007
    Messages:
    1,080
    Likes Received:
    77
    I see your point, but VAD apps use javascript to store variable values, and the null character can't be part of it. You need to escape the value in your DLL and return something different, not the null character.

    Kind regards.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
Thread Status:
Not open for further replies.