-
Notifications
You must be signed in to change notification settings - Fork 24.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Debugging] Please make debug port (8081) configurable #1429
Comments
@bparadie - do you have time to submit a PR for this? |
@brentvatne Right now I don't have a lot of time. But I can prepare a PR. First I wanted to know whether there is interest in this change. It looks like there is, correct? |
I think so. A good approach to make things configurable without stepping on too many toes could be to define a macro like |
Should this also include configuring the IP address (replacing localhost)? |
@jsierles Yeah, I think IP address should be configurable as well. |
@bparadie - agreed! |
@jsierles @ide @brentvatne Before I go ahead and implement something that nobody wants, I'd like to ask you guys whether you find this direction agreeable: Roughly, I was thinking of adding a new dictionary to Then in Also, let me know if you think there are better names for Oh, I almost forgot: Then |
This seems like a good approach. Easy to point people here, and plist files are easy to edit programatically. What about the IPs/ports for non-websocket? |
@jsierles Apologies if this is a stupid question: What are 'non-websocket' IPs/ports? |
@jsierles @ide @brentvatne Just wanted to dog-pile one other idea to this PR. We could change the name from What do you guys think? |
@bparadie: bundles (I assume you mean JS bundles and not iOS asset bundles) and the web socket executor are independent. You could run a bundle across the web socket executor if you wanted. Best to keep the two concepts separate. |
This is the code snippet I am planning to use in NSMutableString* url;
NSDictionary *dict = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"RCTWebSocketExecutor"];
if( dict )
{
NSString* origin = [dict objectForKey:@"origin"];
NSString* port = [NSString stringWithFormat:@"%@", [dict objectForKey:@"port"]];
url = [NSMutableString stringWithString:origin];
[url appendString:@":"];
[url appendString:port];
}
else
{
url = [NSMutableString stringWithString:@"http://localhost:8081"];
} I have three questions:
NSDictionary *dict = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"RCTWebSocketExecutor"];
NSString* origin = [dict objectForKey:@"origin"];
NSString* port = [NSString stringWithFormat:@"%@", [dict objectForKey:@"port"]];
NSMutableString* url = [[[NSMutableString stringWithString:origin] appendString:@":"] appendString:port]; |
@jsierles @ide @brentvatne I have something that works. This is a screenshot after changing the port number to But it's not pretty:
I've create this fake PR against my private repo: As you can see I decided to not switch everything over to Are my changes acceptable? |
@brentvatne np, done: #1546 ! |
Looks good @bparadie! |
+1 |
Here's my hack for how to get Android running mjohnston/react-native-webpack-server#65 (comment) |
I've posted this on product pains so it would be great if you could upvote it there and show the react-native team that this is an important feature https://productpains.com/post/react-native/allow-packager-port-to-be-configurable-change-from-8081/ |
If someone could send a PR it would be great. |
I haven't deleted the branch yet: But I am afraid I am not going to re-submit this PR. I've spent too much time keeping that branch up to date with master and formatting it only to learn that nobody had interested in reviewing and approving it. |
@satya164 Looks like there's a PR now, what else is needed to move this change forward? |
cc @mkonicek |
@berniedurfee-ge Is there a link to the existing PR? I see the closed PR from @bparadie here #1546 @satya164 Looking through that PR it is a little scary to contribute. It seems like people ask for PRs but then aren't reviewing them. Is there any interest from the core team in this feature and would a new PR be handled in a more timely matter? |
@qimingweng, sorry, yes, I was referring to the closed PR. |
@qimingweng The core team is bit busy working on highest requested features (for example 5bf1f4c), and not to say various bug fixes. The number of bug reports and pull requests are overwhelming. We, community collaborators try our best to review small and straight forward PRs. But for bigger PRs, someone from the core team needs to review it. And it can take a long time, both due to the number of open PRs and the size of the PRs. Not that the core team is not interested in merging the PRs. Just that we haven't figured out a better way to keep up such a high volume of PRs. We know we need to improve on this, and looking for ways to improve. |
Since this is being tracked on Product Pains, and we want to keep Github issues focused on bugs, I'm closing this out until another PR pops up or we get more votes on Product Pains. https://productpains.com/post/react-native/allow-packager-port-to-be-configurable-change-from-8081/ |
Hello there, I have fixed this issue by the step below: Step 1: go to \node_modules\react-native\local-cli\server\server.js and change the port 8081 to 8088 const args = parseCommandLine([{ Step 2: Create an "assets" folder under "android/app/src/main" Step 3: in node.js run "react-native start" and navigate to the url "http://localhost:8088/index.android.bundle?platform=android" Step 4: save the bundle to assets folder and you are all set. in node.js run "react-native run-android" to view the result Regards, Hai Tang |
Is this maybe a viable solution to this problem? |
Actually, @haitang3009, we should be able to start the server with a
|
@qimingweng @frantic @bparadie |
@david0673 that solves the localhost problem, not the port problem? |
Is this problem fixed now? Can someone please point me how I can run react native apps in Android and iOS emulators using port other than 8081. |
@abhranilnaha As explained here, you can now set the port for iOS by editing Currently this doesn't make it possible to use the debugger, but it does allow running the apps using a port other than 8081 as you asked (see the last comment here and this issue for more on the debugger problem). |
How can I run |
I couldn't figure out how to get this working following any of the solutions I found online. I found the only reliable way was to replace all occurrences of the hard coded port in the I published an npm package to do this: https://github.com/ktonon/react-native-port-patcher Just install it as a dependency, then add a script for |
Also, just a warning that I'm new new But I haven't tested on Android yet, or done anything beyond launching. |
This still seems to be an issue and searching for a concrete solution has not produced any 100% reliable results for me. I have been able to get Xcode to run doing the following: Xcode: Go to Libraries -> React.xcodeproj -> Start Packager Startup React native using port 8999: Still working on a solution for Android. |
Can we get a way to pass in the IP of our machine running the debugger? Meaning I can just run the way ive been forced to setup a virtual machine makes this damn hard to problem solve |
Port
8081
is currently used byreact-native
as the debugging port in the following files:Unfortunately there are other services that might use 8081, i.e.
McAfee
:See https://kc.mcafee.com/corporate/index?page=content&id=KB66797
Another reason for having a configurable react-native debug port is that I often work on two react-native projects in parallel, i.e. my own project plus
UIExplorer
. But both react-native apps collide, because both want to use port8081
.Please make react-native's debug port configurable in order to avoid conflicts with other services.
The text was updated successfully, but these errors were encountered: