Im not able to connect Tablet to server in PC (LAN) - eclipse

I am using Eclipse WebPlugin that have Jboos servers inside. Muy aplication its deployed inside (Jboss Wildfly- external server) and runs on localhost:8180/foldername
Now I want to conect with my tablet to this server that its runing on my Pc but refuse the connection.
I have tried to open the firewall ports from 8000 to 8200 and I have changed the standalone.xml to allow all IP to conect the server setting the address to 0
<interface name="public">
<inet-address value="${jboss.bind.address:0.0.0.0}"/>
</interface>
But nothing works. here the order of the thing that I want to do:
deploy project on Eclipse Jboss -> run in
localhost:8180/foldername
use the tablet browser to acced to my
PC -> 196.xxx.xxx.xx:8180/foldername
Both computer are in the same subred. some one know what happend or what can i do connect.
Thanks to all

Related

Receiving data from localhost throws 'Connection Refused Error' [duplicate]

I'm running a web service on my local machine that runs at localhost:54722.
I want to call the service from an app running in the Android emulator.
I read that using 10.0.2.2 in the app would access localhost, but it doesn't seem to work with the port number as well. It says HttpResponseException: Bad Request.
You can access your host machine with the IP address "10.0.2.2".
This has been designed in this way by the Android team. So your webserver can perfectly run at localhost and from your Android app you can access it via "http://10.0.2.2:<hostport>".
If your emulator must access the internet through a proxy server, you can configure a custom HTTP proxy from the emulator's Extended controls screen. With the emulator open, click More , and then click Settings and Proxy. From here, you can define your own HTTP proxy settings.
Use 10.0.2.2 for default AVD and 10.0.3.2 for Genymotion
Since 10.0.2.2 is not a secure domain for Android you have to allow non-secured domains in your network configuration for API 28+ where non-TLS connections are prevented by default.
You may use my following configurations:
Create a new file in main/res/xml/network_security_config.xml as:
<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
<domain-config cleartextTrafficPermitted="true">
<domain includeSubdomains="true">localhost</domain>
<domain includeSubdomains="true">10.0.2.2</domain>
</domain-config>
</network-security-config>
And point it in AndroidManifest.xml
<application
......
......
android:networkSecurityConfig="#xml/network_security_config">
I faced the same issue on Visual Studio executing an web app on IIS Express. to fix it you need to go to your project properties then click on Debug Tab and change http://localhost:[YOUR PORT] to http://127.0.0.1:[YOUR PORT] and set the android url to http://10.0.2.2:[YOUR PORT]. it worked for me.
I'm not sure this solution will work for every Android Emulator and every Android SDK version out there but running the following did the trick for me.
adb reverse tcp:54722 tcp:54722
You'll need to have your emulator up an running and then you'll be able to hit localhost:54722 inside the running emulator device successfully.
If you are using IIS Express you may need to bind to all hostnames instead of just `localhost'. Check this fine answer:
https://stackoverflow.com/a/15809698/383761
Tell IIS Express itself to bind to all ip addresses and hostnames. In your .config file (typically %userprofile%\My
Documents\IISExpress\config\applicationhost.config, or
$(solutionDir).vs\config\applicationhost.config for Visual Studio
2015), find your site's binding element, and add
<binding protocol="http" bindingInformation="*:8080:*" />
Make sure to add it as a second binding instead of modifying the existing one or VS will just re-add a new site appended with a (1) Also, you may need to run VS as an administrator.
I solved it with the installation of "Conveyor by Keyoti" in Visual Studio Professional 2015.
Conveyor generate a REMOTE address (your IP) with a port (45455) that enable external request.
Example:
Conveyor allows you test web applications from from external tablets and phones on your network or from Android emulators (without http://10.0.2.2:<hostport>)
The steps are in the following link :
https://marketplace.visualstudio.com/items?itemName=vs-publisher-1448185.ConveyorbyKeyoti
The problem is that the Android emulator maps 10.0.2.2 to 127.0.0.1, not to localhost. So configure your web server to serveron 127.0.0.1:54722 and not localhost:54722. That should do it.
After running your local host you get http://localhost:[port number]/ here you found your port number.
Then get your IP address from Command, Open your windows command and type ipconfig
In my case, IP was 192.168.10.33 so my URL will be http://192.168.10.33:[port number]/.
In Android, the studio uses this URL as your URL. And after that set your URL and your port number in manual proxy for the emulator.
I have a webserver running on my localhost.
If I open up the emulator and want to connect to my localhost I am using 192.168.x.x. This means you should use your local lan ip address. By the way, your HttpResponseException (Bad Request) doesn't mean that the host is not reachable.
Some other errors lead to this exception.
To access localhost on Android Emulator
Add the internet permission from AndroidManifest.xml
<uses-permission android:name="android.permission.INTERNET" />
Add android:usesCleartextTraffic="true", more details here:
Run the below-mentioned command to find your system IP address:
ifconfig | grep "inet " | grep -v 127.0.0.1
Copy the IP address obtained from this step (A)
Run your backend application, which you can access at localhost or 127.0.0.1 from your sytem.
Now in android studio, you can replace the URL if you're using in code or You can use the ip address obtained from step(A) and try opening in web browser,
Like this http://192.168.0.102:8080/
Don't forget to add PORT after the IP address, in my case app was running on 8080 port so I added IP obtained in (A) with the port 8080
you need to set URL as 10.0.2.2:portNr
portNr = the given port by ASP.NET Development Server my current service is running on localhost:3229/Service.svc
so my url is 10.0.2.2:3229
i'd fixed my problem this way
i hope it helps...
"BadRequest" is an error which usually got send by the server itself, see rfc 2616
10.4.1 400 Bad Request
The request could not be understood by the server due to malformed syntax. The client SHOULD NOT repeat the request without modifications.
So you got a working connection to the server, but your request doesn't fit the expecet form. I don't know how you create the connection, what headers are included (if there are any) – but thats what you should checking for.
If you need more help about, explain what your code is about and what it uses to connect to the Server, so we have the big picture.
Here is a question with the same Problem – the answer was that the content-type wasnt set in the header.
1) Run ipconfig command in cmd
2) You will get result like this
3) Then use IPv4 Address of VMWare Network Adapter 1 followed by port number
In My Case its 8080, so instead of using localhost:8080
I am using 192.168.56.1:8080
Done.....
I would like to show you the way I access IISExpress Web APIs from my Android Emulator. I'm using Visual Studio 2015. And I call the Android Emulator from Android Studio.
All of what I need to do is adding the following line to the binding configuration in my applicationhost.config file
<binding protocol="http" bindingInformation="*:<your-port>:" />
Then I check and use the IP4 Address to access my API from Android emulator
Requirement: you must run Visual Studio as Administrator. This post gives a perfect way to do this.
For more details, please visit my post on github
Hope this helps.
For Laravel Homestead Users:
If anyone using Laravel with homestead you can access app backend using 192.168.10.10 in emulator
Still not working?
Another good solution is to use ngrok https://ngrok.com/
I am using Windows 10 as my development platform, accessing 10.0.2.2:port in my emulator is not working as expected, and the same result for other solutions in this question as well.
After several hours of digging, I found that if you add -writable-system argument to the emulator startup command, things will just work.
You have to start an emulator via command line like below:
emulator.exe -avd <emulator_name> -writable-system
Then in your emulator, you can access your API service running on host machine, using LAN IP address and binding port:
http://192.168.1.2:<port>
Hope this helps you out.
About start emulator from command line: https://developer.android.com/studio/run/emulator-commandline.
Explanation why localhost is not available from emulators for anyone who has basic access problem. For sophisticated cases read other answers.
Problem: Emulator has own local network and localhost maps itself to emulator, but NOT your host!
Solution:
Bind your server to 0.0.0.0 to make it available for emulator's network
Get external IP address of your laptop: ifconfig command for Mac
In Android (or Flutter app) use IP address of your external interface like: 192.168.1.10 instead of localhost
I had the same issue when I was trying to connect to my IIS .NET Webservice from the Android emulator.
install npm install -g iisexpress-proxy
iisexpress-proxy 53990 to 9000 to proxy IIS express port to 9000 and access port 9000 from emulator like "http://10.0.2.2:9000"
the reason seems to be by default, IIS Express doesn't allow connections from network
https://forums.asp.net/t/2125232.aspx?Bad+Request+Invalid+Hostname+when+accessing+localhost+Web+API+or+Web+App+from+across+LAN
localhost seemed to be working fine in my emulator at start and then i started getting connection refused exception
i used 127.0.2.2 from the emulator browser and it worked and when i used this in my android app in emulator it again started showing the connection refused problem.
then i did ifconfig and i used the ip 192.168.2.2 and it worked perfectly
Bad request generally means the format of the data you are sending is incorrect. May be mismatched data mapping . If you are getting bad request implies you are able to connect to the server, but the request is not being sent properly.
If anybody is still looking for this, this is how it worked for me.
You need to find the IP of your machine with respect to the device/emulator you are connected. For Emulators on of the way is by following below steps;
Go to VM Virtual box -> select connected device in the list.
Select Settings ->Network-> Find out to which network the device is attached. For me it was 'VirtualBox Host-Only Ethernet Adapter #2'.
In virtualbox go to Files->Preferences->Network->Host-Only Networks, and find out the IPv4 for the network specified in above step. (By Hovering you will get the info)
Provide this IP to access the localhost from emulator. The Port is same as you have provided while running/publishing your services.
Note #1 : Make sure you have taken care of firewalls and inbound rules.
Note #2 : Please check this IP after you restart your machine. For some reason, even If I provided "Use the following IP" The Host-Only IP got changed.
I resolved exact the problem when the service layer is using Visual Studio IIS Express. Just point to 10.0.2.2:port wont work. Instead of messing around the IIS Express as mentioned by other posts, I just put a proxy in front of the IIS Express. For example, apache or nginx. The nginx.conf will look like
# Mobile API
server {
listen 8090;
server_name default_server;
location / {
proxy_pass http://localhost:54722;
}
}
Then the android needs to points to my IP address as 192.168.x.x:8090
if you are using some 3rd party package like node express or angular-cli you will need to find the IP of your machine, and attach your host to that IP within the server startup config (instead of localhost). Then launch it from the emulator using the IP. For example, I had to use: ng serve -H 10.149.212.104 to use the angular-cli. Then from the emulator I used: http://10.149.212.104:4200
If you are working with Asp.Net Web API, in .vs/config folder inside your project, modify these lines as per you port setting. Let suppose you use port 1234 and physicalPath to the project folder set by IIS is "D:\My Projects\YourSiteName", then
<site name="YourSiteName" id="1">
<application path="/" applicationPool="Clr4IntegratedAppPool">
<virtualDirectory path="/" physicalPath="D:\My Projects\YourSiteName" />
</application>
<bindings>
<binding protocol="http" bindingInformation="*:1234:*" />
</bindings>
</site>
In android studio, access your api with "http://10.0.2.2:1234" ...

Allow access to wildfly port 8080 over WAN for web page

My team needs to see a web page I have built that I am hosting temporarily on my local windows 10 laptop using Wildfly 11.
I have changed the configuration standalone.xml from commented value to this
<interface name="public">
<!-- <inet-address value="${jboss.bind.address:127.0.0.1}"/>-->
<inet-address value="${jboss.bind.address:xx.xx.xxx.xxx}"/>
</interface>
Where xxx is equal to my ip address as determined from my internet provider's control page. I can ping that address from any of my local machines and my co-workers can also ping the address.
However, when I go to run with this value in the xml, I get the error:
Failed to start service org.wildfly.network.interface.public: org.jboss.msc.service.StartException in service org.wildfly.network.interface.public: WFLYSRV0082: failed to resolve interface public
What else do I need to do to enable access to the port? Thank you in advance for your help.
If your "xx.xx.xxx.xxx" is not the IP number of an interface on your machine, then you won't be able to bind to it. You can only bind to an interface that is actually present on the host. Typically the IP number of your machine, as seen from the public Internet, will not be the same as an IP number on the machine itself. You need to bind your HTTP server to the machine's real IP number (not localhost, 127.0.0.1, but the IP corresponding to some real network connection -- Ethernet, Wifi, whatever) and you need to configure your Internet router to forward packets addressed to port 8080 to the IP number of your wildfly host.
I would think that, if your co-workers are on the same site as you, they would have access to your machine without going through the public Internet. In that case, all you need to do is to bind the port to the (non-localhost) IP number of your machine, and have your colleagues use that IP number. You might also need to configure any firewall you have -- either on your wildfly host or your router -- to allow access to port 8080.
I would recommend that you run Wildfly on the command line with something like:
bin\standalone.bat -b 0.0.0.0
This will have Wildfly bind to all available interfaces. For testing this should be safe - it should be ok to bind to more than on interface. You will not need any changes in standalone.xml.

Setting default address in Jboss 8 Wildfly

It's my first time deploying apps into web, I've successfully configured ubuntu 14.04 on server, installed java, placed Jboss 8.1.0.Final there.
I'v made also wildfly service. But the problem is that I don't know how to set jboss to start on my default address. For example I have vps555111.ovh.net adress how can I make it to start on that address?
/edit I figured it out how to set it to start it on my address but there's another problem - I was fallowing this tutorial http://www.itbuzzpress.com/wildfly-8-administration/getting-started-with-wildfly-8.html
and when I'm starting it as service it starts on 127.0.0.1:8080 address, anyone?
You can edit you standalone.xml file find the public interface:
<interface name="public">
<inet-address value="${jboss.bind.address:127.0.0.1}"/>
</interface>
And replace 127.0.0.1 with the IP Address you need or 0.0.0.0

A web application running in JBoss EAP through Eclipse cannot be accessed from another computer in the same network

I have a web application (JSF2) running in JBoss EAP through Eclipse in my machine (Computer1). Computer1 is a Windows7 machine.
I can run the application using the Eclipse Internal Browser and Chrome in Computer1.
But when I try to access the application from another computer (Computer2) in the same network, I receive a ERR_CONNECTION_REFUSED error message.
I saw using netstat that Computer1 is listening at port 8080 and Computer1 has no firewall.
I can ping at Computer1 from Computer2.
Any help would be great!
By default JBoss is listening to the local interface only. A quick search reveals that you have to add an interface to your configuration, e.g.:
<interfaces>
...
<interface name="any">
<any-address/>
</interface>
</interfaces>
And then configure the socket-binding-group to use it:
<socket-binding-group name="standard-sockets" default-interface="any">
Reference: https://developer.jboss.org/thread/168789

Wildfly 8 Final - jconsole can't connect remotely

Good day, people,
I am trying to use jconsole to connect to remote Wildfly 8 Final servers. That did not work: Connection failed. After multiple tries and failures I attempted to make it connect at least to my 'localhost' jboss, but even that is not working. No errors, it simply doesn't connect and says "Connection failed".
Details:
Wildfly 8 Final server
Using jconsole from wildfly_installation/bin/jconsole.bat
Management users created. Tried with and without the username/password.
The standalone.xml is the original one, shipped with Wildfly 8 Final without changes
The url that I plug in jconsole to connect to is: service:jmx:remoting-jmx://localhost:9999
The Wildfly/jboss doesn't have anything deployed in it, no WARs/EARs.
Java version is 1.7 release 51. The latest on the moment of writing.
JAVA_HOME points to the only java 1.7 installed on the system.
JConsole can connect to local java process and works, but not remote connection.
Basically it's a brand new installation of Wildfly 8 Final with management user created and jconsole doesn't connect remotely to it.
What else I've tried: I've read many posts on people having troubles with jconsole and Jboss AS 7.x. I have tried the suggestions from those threads, but none worked. Also it seems Wildfly 8 has different JMX version (1.3 vs 1.1 in Jboss 7.x), so I assume that's why standalone.xml suggestions from Jboss 7.x didn't work for Wildfly 8 Final.
Java Mission Control JMX console and Flight Recorder profiler work on WildFly as well.
As already noted the proper JMX connection string is:
service:jmx:http-remoting-jmx://{insert server ip here}:9990
It requires a management user (details on the bottom).
As for the Flight Recorder, these should be added to the server runtime configuration in standalone.conf(.bat):
JAVA_OPTS=%JAVA_OPTS% -XX:+UnlockCommercialFeatures -XX:+FlightRecorder -XX:FlightRecorderOptions=defaultrecording=true
On a workstation where you want to run Java Mission Control you need to adjust the classpath in jmc.ini (located in bin directory of your JDK):
-Xbootclasspath/a:c:\Program Files\Java\jdk1.7.0_67\lib\jconsole.jar;c:\Program Files\Java\jdk1.7.0_67\lib\tools.jar;c:\wildfly-8.1.0.Final\bin\client\jboss-cli-client.jar`
Prerequisites (you most likely already configured this):
this assumes that you have installed JDK on workstation in c:\Program Files\Java\jdk1.7.0_67\
this assumes that you have installed WildFly on workstation in c:\wildfly-8.1.0.Final
on the server you need to have proper bind.address configurations (or <any-address>) in standalone.xml:
<interfaces>
<interface name="management">
<any-address/>
</interface>
<interface name="public">
<any-address/>
</interface>
<interface name="unsecure">
<any-address/>
</interface>
</interfaces>
You need to have a management user on the server, which you can add by using \bin\add-user.bat(.sh).
To test this connect to http://{insert server ip here}:9990 with a web browser which will open the server's web UI console.
Best regards!
Alright, got it figured out. The native management port (9999) was removed in the Final version of Wildfly 8. Now there's only 1 management port (9990) and it has multiple previous ports multiplexed over it, including the JMX. It was still available in the release candidate of Wildfly 8, hence all the confusion about the online instructions and configs available elsewhere online.
So the key is to specify the proper protocol, which is not the remoting-jmx now, but http-remoting-jmx. The URL to connect to the server must be like this:
service:jmx:http-remoting-jmx://<server_host_or_ip>:9990
(this is versus service:jmx:remoting-jmx://:9999 in previous jboss/wildfly servers)
Finally, no need to mess with standalone.xml config. All config tweaks to make it work on Jboss 7.x won't work for it. It all works out of the box with proper protocol and port number. Just make sure to create a jboss user in ManagementRealm.
This was a bug in WildFly that was recently fixed and will be part of 8.0.1 release.
See jira for more details.
You have to include jboss-cli-client.jar in the jconsole classpath:
jconsole -J-Djava.class.path=$JAVA_HOME/lib/jconsole.jar:$WILDFLY_HOME/bin/client/jboss-cli-client.jar
Replace $JAVA_HOME to something like /usr/lib/jvm/java-8-oracle/ and $WILDFLY_HOME to /opt/wildfly/ or wherever you have it unpacked.
And then the url is in the following format:
service:jmx:remote+http://${host}:9990
Also fill in the username and password with the credentials configured using add-user.sh
Below is how to enable the old native JMX interface, removed from WildFly 8 default configuration, which is backwards compatible with JMX tools.
This is required when the new HTTP interface is not an option, e.g. to integrate with legacy tools like Bamboo's JBoss 7 add-on.
Tested with WildFly 10, it should work with WildFly 8 and WildFly 9 as well.
Since the plug in does not support the HTTP management interface, to make it work, we need to enable the native JMX interface, which used to run on port 9999.
This can be done by adding the native-interface element under the management-interfaces section:
<management-interfaces>
<native-interface security-realm="ManagementRealm">
<socket-binding native="management-native"/>
</native-interface>
<http-interface security-realm="ManagementRealm" http-upgrade-enabled="true">
<socket-binding http="management-http"/>
</http-interface>
</management-interfaces>
And defining the corresponding socket-binding
<socket-binding-group name="standard-sockets" default-interface="public" port-offset="${jboss.socket.binding.port-offset:0}">
<socket-binding name="management-native" interface="management"
port="${jboss.management.native.port:9999}"/>
...
If in domain mode, to use the remote endpoint, you set use-management-endpoint to false.
<subsystem xmlns="urn:jboss:domain:jmx:1.3">
<expose-resolved-model/>
<expose-expression-model/>
<remoting-connector use-management-endpoint="false"/>
</subsystem>
Hope it may help anyone...
Reference:
https://docs.jboss.org/author/display/WFLY8/Admin+Guide#AdminGuide-NativeManagementEndpoint