Robot Web Services and Javascript - Remote Access from web application

simbot
simbot Italy
edited April 16 in Developer Tools
Hi All!

As mentioned in the title, I'm trying to code an application in javascript which retrieves data from a robot controller. At the moment I'm testing on a virtual controller with RW 6.12.

I know that in the Developer Center manuals it is said to put the html-javascript files inside the HOME folder in the robot controller, but this is not what I'm trying to reach.

These are the results obtained:
  • Getting data from VC via Postman: OK;
  • Getting data from VC via Node JS libraries: OK;
  • Getting data from VC pasting the URL in the browser address bar: OK;
These results make me think the setup I'm useing is 100% working.


Troubles come when i run a javascript-html script in the browser.

During the authentication process I first get a 401 error as expected.
The problem is that I can't access the www-authenticate response header in which there are all the data needed to complete the authentication.
If I open the Chrome inspection tool the www-authenticate header is right there in the response, but if I try to read it via javascript it just ignores it.
After many reaserches, i got to the conclusion that the browser CORS policy is the reason why this happens.
The solution is probably in the usage of the "Access Control Expose Headers" in the response comeing from the controller.
This implies that you should get access to the server-side code (inside the robot controller) and it's quite impossibile I think.


I think RWS are a great opportunity to develop something that probably other competitors in the robotics field can't, and for this reason ABB should give much more efforts to support developers.


Has anyone solved or at least experienced this problem? Any suggestion, information or link to documentation would be really appreciated.

Thanks in advance for anyone who will try to help.
Best regards.

Comments

  • NilsOlofsson
    NilsOlofsson Sweden admin
    Hello.
    I moved the post to the developer tools category 

    Could you provide some kind of use case where the setup with running everything from a browser so we can get a better understanding of what you could solve by this kind of setup.




    Nils Olofsson
    PC Software Support Engineer

  • simbot
    simbot Italy
    Hi!

    Of course the section was wrong, but i recognized it just a second after clicking "post". Sorry about that.

    If interested I can provide the html and javascript code in private for sure, just message me if so.

    In this moment the setup is:

    • PC 1 - 192.168.1.11 : HTML page with some javascript code. I installed a javascript library found on Github to handle Digest Authentication. Google Chrome used as test environment.
    • PC 2 - 192.168.1.221: Robotstudio running a virtual controller with RW 6.12 and a num variable declared as TASK PERS.

    This is the query string sent:
    100% working with Postman, so no syntax error I suppose.


    At first I get, as expected, a 401 error. This is what I get back in response according to Google Chrome inspection tool:





    As you can see, the www-authenticate needed is righet there. But when I log on the console the headers I can access to via Javascript this is what I get:




    My opinion is that there is something missing on the server side code but I'm not 100% sure about that and I couldn't make any modification in any case.
    As already said, if you need more information, contact me in private, I'll be glad to give you more details.

    Thank you so much


  • NilsOlofsson
    NilsOlofsson Sweden admin
    Hello again.
    It is not possible to just build a browser application to interact with the controller as it is built right now. You would need a server to get around the CORS issues and to be able to do proper cookie management. You could build you own browser but that seems a bit over the top. 
    I was more thinking in terms of possible use cases.
    I am interested to know when you would like a setup like this. A setup with no server where you would only build a frontend and let it interact with the controller

    Nils Olofsson
    PC Software Support Engineer

  • simbot
    simbot Italy
    edited April 21
    Hi Nils,

    thanks for your reply.
    The main idea was to use a web application (built in js and html or whatever you want) just to fetch data from the controller. The browser would act just like an HMI panel where you could send and receive data from the controller, manipulate I/O and so on. This is basically the same thing you can do by putting your application inside the HOME folder in the controller. The difference is that, working dircetly inside the controller, you can just use pure html/javascript but developing your application on a PC (for istance) you would be able to use plenty of different technologies (like VUE, Angular, React, databases, etc.). Hope this make sense.

    I was not considering the idea to build my own browser, of course  :D

    The good news is that we can solve the CORS problem by putting a server application beetwen the controller and the browser. This work-around let you bypass the CORS policies as you said. This seems to be the most resonable solution since I've already made a try and it worked.

    Hope ABB will keep on developing RWS!

    Anyway, thanks for your support!
    Best regards
Sign In or Register to comment.