Welcome to our new forum
All users of the legacy CODESYS Forums, please create a new account at account.codesys.com. But make sure to use the same E-Mail address as in the old Forum. Then your posts will be matched. Close

IP address of connected webvisu = 127.0.0.1

2023-04-07
2024-03-11
  • automatisme - 2023-04-07

    Hello,

    (same post as previously but with a topic title and screenshots)

    I am currently facing an issue regarding reading the IP addresses of webvisu clients connected to a codesys runtime for sl3300 wago.

    After implementing the iterateClient block, I am unable to read any addresses other than the loopback address 127.0.0.1. Despite this, the iteration process seems to be functioning correctly, as the names of the different views displayed on the various pages change correctly as we navigate through the respective webvisus.

    However, the IP addresses of the clients do not take on any values other than 127.0.0.1

    Picture 1
    Picture 2

    What am I missing here?

     
  • sedoerr - 2023-04-11

    I have done it like this:

    FUNCTION CheckClientData : ARRAY[0..5] OF VisuClientData
    VAR_INPUT
    END_VAR
    VAR
        pClient     : POINTER TO VisuElems.VisuElemBase.VisuStructClientData;
        pClientTmp  : POINTER TO VisuElems.VisuElemBase.VisuStructClientData;
        DataHelper  : VisuElems.VisuFbClientTagDataHelper;
        i           : UINT;
    END_VAR
    
    VisuElems.g_ClientManager.BeginIteration();
    
    WHILE (pClient := VisuElems.VisuElemBase.g_ClientManager.GetNextClient()) <> 0 DO
        IF pClient^.GlobalData.ClientType = VisuElems.VisuElemBase.Visu_ClientType.WebVisualization THEN
            IF pClientTmp <> pClient THEN
                DataHelper(pClientData := pClient);
    
                    CheckClientData[i].ClientIP             := DataHelper.stIPv4;
                    CheckClientData[i].CurrentUserName      := pClient^.GlobalData.CurrentUserName;
                    CheckClientData[i].CurrentFullUserName  := pClient^.GlobalData.CurrentFullUserName;
                    CheckClientData[i].CurrentUserGroupName := pClient^.GlobalData.CurrentUserGroupName;
    
                pClientTmp := pClient;
    
                IF i <= UPPER_BOUND(CheckClientData,1) THEN
                    i := i + 1;
                    ELSE i := 0;
                END_IF
    
            END_IF
        END_IF
    END_WHILE
    
    TYPE VisuClientData :
    STRUCT
        ClientIP                : STRING(15);       //IP-Adresse
        CurrentUserName         : WSTRING;
        CurrentFullUserName     : WSTRING;
        CurrentUserGroupName    : WSTRING(511);
    END_STRUCT
    END_TYPE
    
     
  • automatisme - 2023-04-11

    Hello,

    Thanks foryour answer.

    I copy pasted you code in a new program, just made small adjustment to avoid having several reference of the same client in de "CheckClientData" array. Still got "127.0.0.1".

    I also asked the question to wago support, I hope I'll get an answer. It is very important for us to be able to identify each screan and also check that no unintended client connect to the machine.

    Is there a specific task or a (preferential one) where to call this function? Is it ok to do it in visu_task?

     
  • ben1 - 2023-04-17

    Sorry, so in your original post, is it correct that the 3 stCurrentVisu[x]'s are 3 different pages being accessed on 3 different PC's (or HMI's)?

    I have used this similar function before on 2 devices and it worked, I would have to locate where though....

     
  • automatisme - 2023-04-17

    Yes, that's right stCurrentVisu refers to three visualizations displayed on 3 different machines.
    I think the problem comes from the integration of the 3S runtime by Wago. I don't see why it wouldn't work otherwise.
    On what type of runtime have you seen this function working correctly?

    For your information, the edge controller from Wago is a machine based on LInux, but the runtime used is not the runtime for Linux, it is a particular version made by Wago.

     
  • ben1 - 2023-04-17

    It sounds like you are right, if the CurrentVisu's are coming through it has to be cycling correctly! The code def looks right.

    I believe it was one on a PC and the other was on a Schneider HMI, so Vijeo Runtime?

     
  • jinlee - 2024-03-11

    Hi,

    Did you manage to solve the problem ? I have the same issue of reading 127.0.0.1 only.

     

Log in to post a comment.