B4J Question B4J socket.IO

Discussion in 'B4J Questions' started by fbritop, Oct 11, 2019 at 11:40 PM.

  1. fbritop

    fbritop Active Member Licensed User

    I have the following scenario. A desktop PC running chrome connected to a public SSL site. This web app sometimes receives a message with data from a barcode reader. Here it where the truth comes.


    I did a VB daemon to act as a webSocket server. The browser connects to this “localhost” WS Server. When the daemon reads a barcode, the daemon sends a message to the browser and some action is taken.


    Here´s where the trouble comes. The client website and browser are connected to a public IP with a valid SSL certificate, so you are under SSL, the WS Client on the browser, requires mandatory WSS connection. So, if I try WSS connection to the daemon at localhost, it denies the outbound connection from Chrome because the certificate is invalid (obvious as there is no certificate for localhost because of the Middleman Attack problem)


    What are my choices, of building some kind of message broker with B4J to connect with javascript or any other method from B4J to the browser and vice versa? Is there socketIO server in B4J possible? I already use socketIO to real time notifications between the user and the server.


    One solution would be that the scanner posts the data to my external server, and my server forwards the message to the browser, but we need direct LAN connection. Also try with WebRTC, but again we need a signaling public App to build the config and routing, although routing is local.


    Any use cases that a browser under SSL, can do direct message broker to a B4J app running in the same LAN/IP/Local?
     
  2. OliverA

    OliverA Expert Licensed User

    Why are you doing this/need to do this?
    What OS is on “localhost”?
     
  3. fbritop

    fbritop Active Member Licensed User

    Usually Windows. Althow it can be linux or Mac. Thats why I´m aiming to B4J and not VB.Net

    I need this, in order to scan the PDF file on the national Identity Card, which contains among another things, the minutae of the fingerprint
     
  4. OliverA

    OliverA Expert Licensed User

    From what I understand, you have a public website that has a websocket service running. Let's call it
    and you access a wss service with Chrome via (as an example)
    That site is hosted on a PC on your network. On that PC, you are trying to access the same service using chrome via
    and Chrome complains about the security certificate.

    If that describes your case, then all you have to do is add the following line (adjusted with the domain that you are trying to access) to your hosts file on your PC
    You can then access your site on the PC via
    And Chrome should not be complaining about the certificate

    Link:
    How to edit hosts file: https://www.howtogeek.com/howto/27350/beginner-geek-how-to-edit-your-hosts-file/

    Note(s):
    If you are trying to have other computers access your server locally (without going through the internet) then you have a couple of options:
    1) If you router lets you manually add DNS entries, then enter a DNS entry for your server, using the server's local IP address for the IP address the DNS server points to. Some routers let you use the MAC address instead of the IP address, thus allowing for dynamic IP assignment.
    2) You could modify the hosts file on each PC on the network
    3) If you are running a Windows Domain, you could add an entry for your server to the DNS server on your domain
    4) If you use your own DNS server internally (Linux, etc), the add the entry to your DNS server
     
  5. KMatle

    KMatle Expert Licensed User

    Use OkHttpUtils and f.e. php to communicate with (your?) Server.
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice