Setting up weinre remote debugging - weinre

Instructions for running weinre state that I need to insert following script:
<script src="http://a.b.c:8081/target/target-script-min.js"></script>
where http://a.b.c is my server IP or host name.
Couple of questions:
Does this mean that I must open port 8081 on my remote server?
Also what is the target-script-min.js? It looks like I need to upload it to a target folder?

The way you start the weinre sever is by running the command
weinre
in your command line. And then you leaving it running for as long as you're still using weinre. You have options for this command that you can find by type weinre --help, but the important ones are --boundHost, and --httpPort. --boundHost defaults to localhost and --httpPort defaults to 8080. So run
weinre --boundHost 192.168.1.2
where 192.168.3.4 is your ip address, which you can find by running ipconfig. Put the following in your code:
<script src="http://192.168.1.2:8080/target/target-script-min.js#whatever"></script>
Then, in your browser, go to
http://192.168.1.2:8080/client/#whatever
I wrote a blog post about it here: https://adam.garrett-harris.com/how-to-setup-remote-debugging-in-phonegap
To answer your second question, the target-script-min.js is just a javascript file that's a part of weinre whenever you install it. When you have weinre running, you can visit
http://192.168.1.2:8080/target/target-script-min.js
to see the file if you want.

The weinre server is "started" by executing this command weinre --boundHost a.b.c.d where a.b.c.d stands for the local IP of the desktop used for debugging. The port 8080 will be opened (default port, but you may configure an other one).
At this point, the script http://a.b.c.d:8080/target/target-script-min.js becomes available on your local network, and may be called by your application located on an other device in the same local network.
If your application or tested web page call this script, it will be seen by your desktop.
Therefore, you don't have anything to upload on your target...

Weinri debug resume
After successfully installed weinri,
1 - Run this command with your ip address:
weinre --boundHost 192.168.12.3
2 - Attach in your code header:
<script src="http://192.168.12.3:8080/target/target-script-min.js#anonymous"></script>
3 - Access your website in your tablet or whatever device
3 - Get the wenri debug screen on:
http://localhost:8080/client/#anonymous
Obs: 'anonymous' word can be replaced by another of your choice.

if you can't debug your html page even after completing all of the steps mentioned in the Nokia Developer Article,
then check your windows firewall settings.Please be sure that the firewall setting for private network is TURNED OFF ..

Related

Issues connecting Vagrant Xdebug with PhpStorm 2020.3

Have spent over a day trying to get PhpStorm to debug a Drupal site inside a Vagrant virtual machine running Xdebug and I feel I'm close - but just not quite there yet.
Currently, in PhpStorm when debugging I have an error:
Waiting for incoming connection with ide key 'PHPSTORM'
In the Xdebug log in the VM (at /tmp/xdebug.log)
[2094] I: Checking remote connect back address.
[2094] I: Checking header 'HTTP_X_FORWARDED_FOR'.
[2094] I: Checking header 'REMOTE_ADDR'.
[2094] I: Remote address found, connecting to 192.168.88.1:9000.
[2161] E: Time-out connecting to client (Waited: 200 ms). :-(
[2161] Log closed at 2020-12-15 04:25:32
I tried setting up the Zero-configuration debugging without any luck.
For the debugging configuration, I have a PHP Remote Debug that validates correctly although it always defaults to the 'Local Web Server or Shared Folder' rather than the 'Remote Web Server' option.
When I started the project I set it up as a local web server option and I'm worried that I haven't changed the correct settings to now make this a remote web server. The connection type for the deployment is now 'Local or mounted folder' but originally this was 'In-place'.
Under Languages & Frameworks --> PHP --> Servers, I set this up on port 80, using Xdebug and without path mappings. I tried changing the port etc but then it doesn't validate so I'm confident that the server settings are correct and that PhpStorm is talking to the virtual machine correctly.
I changed the /etc/php/7.4/cli/php.ini file but phpinfo() says the configuration is coming from /etc/php/7.4/fpm/php.ini. The changes I made in the php.ini file are active though. phpinfo() is showing:
xdebug.idekey: PHPSTORM
xdebug.remote_host: 10.0.2.2
xdebug.remote_port: 9000
xdebug.remote_autostart: Off
xdebug.remote_connect_back: On
Really at a loss now as to what to try next. It is incredibly frustrating so hope someone can shed some light.
EDIT --- As per comment here is the screenshots of the setup:
Deployment: Local or mounted folder
PHP settings
The server setup
Debug settings
Validate the debugger from the remote server
Run Chrome with the debug addon running
The error message
The Run debug configuration settings
Start of the phpinfo with the config file showing where the xdebug settings need to be edited.
The Xdebug settings of phpinfo()
Some of the tests as per the comments:
After logging in to 'vagrant SSH' it shows the IP address to be used (10.0.2.2). The local computer is also IP 10.1.1.150 a telnet test of both of these works.
A 'sudo nano' of the Xdebug ini file
NOTE: Changing the remote connect back to 0 fixed the connection:
xdebug.remote_connect_back=0
And then the path mapping needed to be turned on in the Server settings and then everything was working correctly.
Big thanks to LazyOne for his helpful and thorough comments. :)
1) Check if there are separate php.ini files used by web server, -- you need to edit the right php.ini file.
Run phpinfo() and check to see if there is an ini file for Xdebug. In my case this was at /etc/php/7.4/fpm/conf.d/20-xdebug.ini
2) What's your Xdebug version?
Version 2 and 3 of Xdebug have slightly different parameters. In my case I was running Xdebug 2.9.5
3) What is the IP address of your Host OS as seen from the inside the VM? That's where Xdebug should connect (as it's Xdebug that connects to IDE and NOT other way around).
When you first log in to the SSH there will be an IP address shown. This is what the IP should be for Xdebug. In my example, this was 10.0.2.2
4) xdebug.remote_connect_back: On -- try set it off and ensure that you have correct xdebug.remote_host (as Xdebug v2 may not fallback to remote_host value when autodetected IP fails.
This fixed my connection!
sudo nano /etc/php/7.4/fpm/conf.d/20-xdebug.ini
Then change:
xdebug.remote_connect_back=1
To:
xdebug.remote_connect_back=0
Save, and then restart the server.
Test the connection again. After this step I had a connection between the host and remote server but I also had to turn on path mapping in PhpStorm to get the debugger working 100%.
5) Ensure that PhpStorm is the one that listens on Xdebug port when "phone handle" icon is enabled (use netstat or alike to confirm) and is allowed in firewall.
6) If you know the correct IP and sure that PhpStorm is listening -- you can just use telnet from inside the VM and try to connect to IDE on Xdebug port -- if connected then IP, port and firewall is most likely set up correctly.
Even with the error messages, the telnet check was working. So it pointed to the issue being with the Xdebug setup rather than the handshaking between the host and remote server.
Thanks to LazyOne's comments for finding the answer and for presenting a great workflow to help identify the problem.
I was experiencing something very similar to what you described.
I was able to start a debug session from the xdebug cli tool (dbgpClient) which proved to me that it was an issue with phpStorm.
My project is using a legacy version of xdebug. (2.2.7)
Downgrading to phpStorm 2020.2.4 resolved my issue.
(It's one-click in the jetbrains toolbox to downgrade)
Thanks for the answers in this issue. It took me half a day to find out that xdebug 2.2.7 with php5.3.10 doesn't work on Phpstorm 2020.3. So I downgraded to 2020.2.4 and it works again.

create react app On Your Network with WSL2 not working

I am trying to use a mobile device to view the app served by create react app. When I open the IP:PORT recommended by CRA's "On Your Network", the page never loads on my mobile device.
I am working on Windows 10 laptop, using WSL2 with Ubuntu. My network is all wifi, no ethernet cables. My code is on the Ubuntu file system and I run npm start from the same location in a WSL terminal from VS Code with the WSL extension.
I am able to see the app using http://localhost:3000 with browsers on my Windows machine (Chrome, Edge).
I noticed cmd.exe ipconfig lists the IP address that corresponds to "On Your Network" as "Ethernet adapter vEthernet (WSL)". This IP address (172.17.144.244) is different than what ipconfig shows as "Wireless LAN adapter Wi-Fi" (192.168.1.23). I also tried 192.168.1.23:3000 on my mobile device, but it didn't work either.
Some other posts on SO recommend removing a firewall setting that blocks NodeJS applications. I scrolled through the many applications listed in the firewall settings and found nothing for NodeJS apps.
Since WSL2 uses a virtual NIC what you need is enable port forwarding in the Firewall otherwise your server in WSL2 won't be seen by external PCs in your network.
I recommend reading the entire thread but in resume you can start using this script:
https://github.com/microsoft/WSL/issues/4150#issuecomment-504209723
I had the same issue. So instead of trying to restart the Windows, try to open the Powershell terminal, shut down the WSL, and then start it again. it solves to me.
Command to shut down: wsl --shutdown
Command to start: to start: wsl
Source: https://github.com/microsoft/WSL/issues/4885#issuecomment-803881561
I found a tool that fixes this problem: https://github.com/icflorescu/expose-wsl
First you need to run the command in the wsl terminal
npx expose-wsl#latest
and it gives you an ip address of your pc 192.168.0.130 for example, with that ip you can access the project from devices on the same network.
When running npm start:
.
.
.
On Your Network: http://172.48.228.88:3000
enter on mobile device:
http://192.168.0.130:3000
and works.
Note: You have to allow the port through the Windows firewall. In my case the firewall should allow access to 'C:\Program Files\WindowsApps\MicrosoftCorporationII.WindowsSubsystemForLinux_1.0.3.0_x64__...\wslhost.exe'
You can run your app in Docker instead and use Docker for Windows, enabled for WSL2. It somehow manages dynamic dynamically forward the ports, without having you to change anything in Windows.
I was also having the problem with hot reloading in WSL2 . I tried almost every solution present on github , stackoverflow and where not , from CHOKIDAR_USEPOLLING=true to setting FAST_REFRESH= false in .env file to changing network setting using netsh.... but none of them worked for me and after 2 days of searching solutions and trying to fix it .. finally reverted to wsl 1.
Just run this command on Powershell for now.
wsl --set-version Ubuntu-20.04 1
Consider Nginx for Windows.
I prefer this solution because I'm more familiar configuring web servers and reverse proxies than Windows networking and Powershell.
After unzipping the distribution, for example at C:\somepath\nginx-1.22.1, I add the following reverse proxy configuration to C:\somepath\nginx-1.22.1\conf\nginx.conf
...
http {
...
server {
listen 11500;
server_name wsl2_server;
charset utf-8;
location / {
proxy_pass http://localhost:11500/;
}
}
...
As you can see, I have a web server running on port 11500 in WSL2. When my mobile device requests "lan_ip_of_laptop:11500/", it then forwards to localhost:11500 and WSL2 server completes the request.

Port 8005 is used By Windows 10 System Process

Since today, the port 8005 is used for a Windows System Process. When i try to acces to the url http:localhost:8005 ,i can see a Blank Web Page, with no code and no info from any Web Server (No welcome web page or similar).
With the netstat command i can see that the process that uses this port is System process. Any idea why windows is using suddenly this port?
EDIT: Not duplicate question. I don't have another Tomcat installation, the problem comes from a windows process, not for another tomcat instance.
Check if port 8005 is really in use by Windows :
Install and run Sysinternals TCPView and
Check if the line with "Local Port" 8005 has as "Process" System
Or check the file c:\Windows\CCM\Logs\DeltaDownload.log for port 8005
If the port is in use by system, go to Computer Management and stop the service "SMS Agent Host" or open a command prompt as administrator and type:
sc stop CcmExec
The problems comes from a Windows Service:
https://www.niallbrady.com/2017/02/15/how-can-i-use-express-updates-when-patching-windows-10-with-quality-updates-in-system-center-configuration-manager-current-branch/
Not from another Tomcat instance.
I too was facing the same with windows 10 and ran the command netstat -a -b which showed CmRcService.exe is using the port 8005 on the machine.
The most weird part is sometimes if i hit localhost:8005 in the browser url its asking for username and password to access the page and in the developers tools I cannot see any application name or data whatsoever

xdebug remote server and SFTP - cannot connect

I am trying to debug PHP files which sit on a remote server (on the same network) without success.
Here is my php.ini config for xdebug on the remote server where PHP and xdebug are installed:
xdebug.remote_enable=1
xdebug.remote_host=192.168.128.56
xdebug.remote_port=9000
xdebug.remote_handler=dbgp
xdebug.remote_autostart=0
192.168.128.56 is the IP address of my PC on which my editor is installed.
I have tried to get this working with both Atom and Sublime Text 3 without success. I think that my path bindings may be incorrect.
I log into the remote linux machine using SFTP. I can then double click on php files in my application and they will open in my editor where I can work on them and save them. How can I set up the path bindings to debug these remote php files? I'm not sure what the second (local) part of the path binding should actually be? Do I need to add the location where the FTP software stores a temporary copy of the file I am working on as the local part of the binding?
I have tried the following:
URL - the address of where the app runs on the remote server:
e.g. http://www.mywebsite.com/testapp/
Path Binding - remote path to the application root on linux : path to the local copy of the files on my machine where the FTP software stores them:
e.g. /web/testApp/ : C:\Users\me\AppData\Local\Temp\scp18929\
I'm a little confused about how the path binding works, and what the values should be. Am I doing this correctly? Can this even be done?
If anyone can help that would be great.
Probably, the first thing to check is whether Xdebug actually tries to connect to your IDE. You can do that, by adding:
xdebug.remote_log=/tmp/xdebug.log
to your php.ini file. When you then initiate debugging, there should be information in the /tmp/xdebug.log file, where it will tell you where it tried to connect too, and whether the connection succeeded or failed.
If you get something like:
I: Remote address found, connecting to 192.168.128.56:9000.
E: Could not connect to client. :-(
That means that either your IDE wasn't listening for something, or that there is a firewall preventing an incoming connection, or that the IP address is incorrect.

Port localhost:3000 does not respond

I use Windows and I ran the .msi.
localhost:3000 does not respond. I activated and rested iis and cannot see anything under 3000. How can I check if the port is active and if anybody s listening? I tried lsof -i in cmd and I get the error "lsof unrecognized batch file"
Also, when I run meteor from the directory with the example or dummy, I do not have anything else following like
..running, port localhost:3000 active
It doesn't look like the command 'meteor' does anything on my machine.
Do I need to put my meteor folder inside the installation one (i.e. C:/Program Files(x86)/meteor)
Since this question was posted, Meteor has gotten an official Windows installer. See if it works now.

Resources