Difference between revisions of "SimpleWebServer"

From AdvancedHMI
Jump to: navigation, search
 
(6 intermediate revisions by the same user not shown)
Line 1: Line 1:
This is a VERY basic component that sends a snap shot of the AdvancedHMI page.
+
This is a VERY basic component that sends a screen shot of an AdvancedHMI form to a web browser.
  
 
To use:
 
To use:
  
1) From the Toolbox place the SimpleWebServer on the form
+
1) From the Toolbox place the SimpleWebServer on the form</br>
2) Set the TCPPort property to 8080
+
2) Set the TCPPort property to 8080 (This can be left at 80 if you know for sure there is not already a web server on your PC)</br>
3) Set SourceForm property to the form you wish to display
+
3) Set SourceForm property to the form you wish to display</br>
4) Start the application
+
4) Start the application</br>
5) In a web browser, enter the IP address of your PC along with the port number
+
5) In a web browser, enter the IP address of your PC along with the port number</br>
 
   http://192.168.1.111:8080
 
   http://192.168.1.111:8080
  
Line 14: Line 14:
 
It can be tricky to make it work. If it doesn't work there are 2 likely possibilities. The first is that it attached itself to another Ethernet port than the one you specified the IPAddress. To troubleshoot this:
 
It can be tricky to make it work. If it doesn't work there are 2 likely possibilities. The first is that it attached itself to another Ethernet port than the one you specified the IPAddress. To troubleshoot this:
  
1) In Solution Explorer, expand down the AdvancedHMIControls project
+
1) In Solution Explorer, expand down the AdvancedHMIControls project</br>
2) Expand down the Components folder
+
2) Expand down the Components folder</br>
3) Right click the SimpleWebServer.vb and select View Code
+
3) Right click the SimpleWebServer.vb and select View Code</br>
4) Go to approximate line 107 and look for this code:
+
4) Go to approximate line 107 and look for this code:</br>
  
 
         Try
 
         Try
        server = New TcpListener(localAddr, m_TCPPort)  ''<-- place break point here''
+
            server = New TcpListener(localAddr, m_TCPPort)  ''<-- place break point here''
 
             server.Start()
 
             server.Start()
 
             server.BeginAcceptTcpClient(AddressOf ConnectionAccepted, server)
 
             server.BeginAcceptTcpClient(AddressOf ConnectionAccepted, server)
Line 26: Line 26:
 
             Console.WriteLine("SocketException: {0}", e)
 
             Console.WriteLine("SocketException: {0}", e)
 
         End Try
 
         End Try
5) Click in the left margin to place a break point next to the line after "server = New TcpListener(localAddr, m_TCPPort)"
+
5) Click in the left margin to place a break point next to the line after "server = New TcpListener(localAddr, m_TCPPort)"</br>
6) Run the application
+
6) Run the application</br>
7) When it stops at the breakpoint, hover over localAddr and see what the IP address is
+
7) When it stops at the breakpoint, hover over localAddr and see what the IP address is</br>
8) Use the address in your browser along with the port number as shown above
+
8) Use the address in your browser along with the port number as shown above</br>
 +
 
 +
 
 +
The other common problem is a port conflict. When starting the application, check the Visual Studio output window to see if it shows a Socket Exception.

Latest revision as of 14:53, 9 June 2019

This is a VERY basic component that sends a screen shot of an AdvancedHMI form to a web browser.

To use:

1) From the Toolbox place the SimpleWebServer on the form
2) Set the TCPPort property to 8080 (This can be left at 80 if you know for sure there is not already a web server on your PC)
3) Set SourceForm property to the form you wish to display
4) Start the application
5) In a web browser, enter the IP address of your PC along with the port number

  http://192.168.1.111:8080


It can be tricky to make it work. If it doesn't work there are 2 likely possibilities. The first is that it attached itself to another Ethernet port than the one you specified the IPAddress. To troubleshoot this:

1) In Solution Explorer, expand down the AdvancedHMIControls project
2) Expand down the Components folder
3) Right click the SimpleWebServer.vb and select View Code
4) Go to approximate line 107 and look for this code:

       Try
           server = New TcpListener(localAddr, m_TCPPort)   <-- place break point here
           server.Start()
           server.BeginAcceptTcpClient(AddressOf ConnectionAccepted, server)
       Catch e As SocketException
           Console.WriteLine("SocketException: {0}", e)
       End Try

5) Click in the left margin to place a break point next to the line after "server = New TcpListener(localAddr, m_TCPPort)"
6) Run the application
7) When it stops at the breakpoint, hover over localAddr and see what the IP address is
8) Use the address in your browser along with the port number as shown above


The other common problem is a port conflict. When starting the application, check the Visual Studio output window to see if it shows a Socket Exception.