Accessing server program on local machine from Android emulator - android-studio

I'm running a small Java server program on my local machine using a serversocket listening on port 12345.
I want to communicate with the server from android app running in android emulator. Using address 10.0.2.2 and same port I get the following Exception:
java.net.SocketException: Permission denied
I also included the following tags in my manifest:
uses-permission android:name="ANDROID.PERMISSION.ACCESS_NETWORK_STATE"
uses-permission android:name="ANDROID.PERMISSION.INTERNET"
The emulator tries to connect to the server when a button is clicked. It works perfectly when I run the server and client program on my local machine using localhost as the address.

Solved. I just hat do configure the firewall. Adding a new rule allowing incoming connections on given port and address was the way to go.

Related

Connect to remote Azure Linux machine through ssh Visual Studio Code

I want to connect to an Azure machine on which is installed an Ubuntu distribution.
I can connect or through ssh or, by installing some other software, by using X2Go.
However, I don't need the UI and if it's possible I would like to use Visual Studio Code.
On this last I've installed the ssh component and I've already used it to connect to other machines.
Unfortunately I'm not able to connect to the Azure machine by using VS Code.
The ssh connection works, I tested it by connecting through the terminal.
The connection string is in the following for:
(user_name)#(machine_name).westeurope.cloudapp.azure.com
I'm not the system administrator and I don't know the public IP.
I think the problem is the ssh port, I read that the standard port for ssh is 22 while I have 53044.
On VS Code I tried the following solution:
connection string: (user_name)#(machine_name).westeurope.cloudapp.azure.com:53044
I added the connection info into the config file with this format:
Host Linux_Azure
HostName (machine_name).westeurope.cloudapp.azure.com
User (user_name)
Port 53044
None of them work.
With the first solution VS Code tries to connect forever, failing with no error messages.
With the second solution VS Code gives back this error message: Could not establish connection to "Linux_Azure": The connection timed out.
I don't understand why it doesn't work, and I don't know how to solve it.
Do you have any idea to solve it?
I deployed one Ubuntu VM and tried connecting to it via SSH in VS code and got connected successfully with Port 22 like below:-
ssh siliconuser#siliconlinuxvm123.centralindia.cloudapp.azure.com -p 22
Output:-
When I tried connecting with port 53044, Even I got the same error code as yours like below:-
By default Azure Linux VM uses Port 22 to SSH, You cannot change the default destination port as it is fixed for a particular protocol. Example For RDP - Port 3389 is used, For HTTP- Port 80 and for SSH- Port 22 is used.
When I try to allow SSH in the inbound rule on VM's Networking Page > Port 22 is selected by default and greyed out thus we cannot add other port as a destination range refer below:-

Docker Xdebug LAN / Public Dev server

I want to get Xdebug running in a semi secure manner over LAN in the office. Our current setup is as follows:
Local server on LAN network under 192.168.1.1 with Ubuntu Server 16
Multiple instances of docker with PHP / Apache running on Ubuntu server
Jwilder nginx proxy for forwarding all requests to individual docker containers
https://github.com/jwilder/nginx-proxy
Files are directly edited over an internal SMB share where Windows hosts connect to the Linux share. These are the hosts running PhpStorm.
The machine is exposed to the world using port 80. LAN has access to all ports.
I'm at a bit of a loss how to properly setup Xdebug using PhpStorm where only those within our LAN can trigger the debugger and debug from map files from a Linux host on Windows.
A DBGp proxy would be the answer here.
It limits all debugging connections from the web server to a single host inside the LAN.
It allows you to perform multi-user debugging with the help of IDE keys.
JFYI, in Xdebug, it's the web server that initiates a TCP connection to the client (the DBGp proxy in this case), so some Docker networking magic is required here.

Local host is not comming up on android emulator

I have been trying to run my app on android emulator and send requests to my node js local host but localhost:3000 is not working in emulator i also tried 10.0.2.2 and 10.0.3.2 im using Andy android Emulator and my server is up on windows localhost:3000 works on windows but nothing works in the emulator what should i do?
Did you try this ?
10.0.2.2:3000
this should work.
if this is not working check that you're server is up and running on port 3000
Finally i found the solution:
first you should run ipconfig command than there is an ip in one of of the adapters that it bring ,in front of the ipv4 ,mine was 192.168.1.4 you should that ip with :3000 then you can access your local host.
I was using Nox app player

Angular 4 Failed to load resource: net::ERR_CONNECTION_REFUSED

I guess I will start at the start of my application.
I am making a full mean-stack application and I want it to run in docker. To use docker I am using a virtualbox with Ubuntu. When I run my docker-compose, everything is working on localhost:4200. Now I want to open my application on my host machine (Windows 7).
When I go to my application via (ip addres should be kept secret, right?) xxx.xxx.xx.xxx:4200/login the page looks fine, but I get these errors:
I am using Angular cli 1.4.1 with node 8.4.0
Why am I getting these errors and how do I fix them?
My docker-compose
Your server which is listening on port 4200 is listening on your xxx.xxx.xxx.xxx interface (not necessary to hide lan IP, but nevermind...).
Your angular application is running on your host system. the localhost is the localhost of your host system, not the guest. so you have two solutions:
changing your urls inside the angular application to point to xxx.xxx.xxx.xxx:4200 instead of localhost:4200.
Forwarding your 4200 port from your host to your guest system using virtual box :
shutdown guest.
select guest and click on settings
go to the network tab.
click on "advanced"
then select "ports redirections" and bind your host 127.0.0.1:4200 to your guest's 4200 port

How to access nginx server from host machine, installed on guest VM ?

Host Machine - Win 7
Guest - Fedora
I have installed nginx web server on guest fedora machine and I can access the webpage inside guest machine using the interface address. How can I access the web page from host machine's browser ?
I am using bridged connection.
Router is assigning 192.168.0.16 to the guest machine's interface. I tried same address in my host machine but it doesn't work.
Based on your description:
First you should check your web application's config. You don't mention which type of your web application running on your Apache server, some are launched with the specific ip argment 127.0.0.1( or localhost), so kind of these web application can only be visited on your localhost computer. You should change the ip argument to 0.0.0.0
Second if the "Fisrt" failed, check the connection of the two server(host and your guest) by using telnet.
On your Win7, you can use the command:
telnet ip port
for example:
telnet 192.168.0.16 80
80 is the default port of Apache Http(s) Server.
if the command don't show the "connection refused" error, your Apache server is goood, so it might be something wrong of your web application.
If that, show me your error msg then we go on further.

Resources