square / PonyDebugger

Remote network and data debugging for your native iOS app using Chrome Developer Tools
Other
5.87k stars 595 forks source link

Debugger failed with web socket error when running a real device #148

Open yiplee opened 9 years ago

yiplee commented 9 years ago

here is the code

PDDebugger *debugger = [PDDebugger defaultInstance];

  [debugger enableNetworkTrafficDebugging];
  [debugger forwardAllNetworkTraffic];

  [debugger enableCoreDataDebugging];
  [debugger addManagedObjectContext:[NSManagedObjectContext MR_defaultContext] withName:@"Main MOC"];
  [debugger addManagedObjectContext:[NSManagedObjectContext MR_rootSavingContext] withName:@"Root MOC"];

  [debugger enableViewHierarchyDebugging];
  [debugger setDisplayedViewAttributeKeyPaths:@[@"frame", @"hidden", @"alpha", @"opaque"]];

#if !TARGET_IPHONE_SIMULATOR
 [debugger autoConnect];
#else
  [debugger connectToURL:[NSURL URLWithString:@"ws://localhost:9000/device"]];
#endif

here is the log screen shot 2015-04-15 at 09 19 13

BTW , it works well on a simulator .

wlue commented 9 years ago

How are you running ponyd? If you want it to listen to connections outside of your computer, make sure you run ponyd with -i 0.0.0.0

yiplee commented 9 years ago

@wlue Thanks for your reply . I have tried -i 0.0.0.0 but failed with response code 403 when conecting .

screen shot 2015-04-18 at 12 39 53

JonathanBouaziz commented 9 years ago

Did you ever resolve the issue @yiplee ?

Nadzeya-Zomato commented 8 years ago

Hi, guys! Did you solve this issue? @yiplee @JonathanBouaziz? I've faced with the same problem. I've solved it in this way. Instead of [debugger connectToURL:[NSURL URLWithString:@"ws://localhost:9000/device"]]; Put your real IP-address. Smth like:

PDDebugger *debugger = [PDDebugger defaultInstance]; [debugger connectToURL:[NSURL URLWithString:@"ws://10.0.2.120:9000/device"]];

gruhls508 commented 8 years ago

@Nadzeya-Zomato what do you mean by "your real IP-address?" Might be a noob thing to ask, but would this be the IP address for local-host? I'm not too versed in web/server things

dstd commented 8 years ago

@gruhls508 as the subject says it's all about app running on real device. So if you use localhost as the address in connectToURL, then your app will try to find the PD server (ponyd) on the iPhone. That's why you have to specify address of your Mac, where ponyd is running.

So:

  1. use 0.0.0.0 address for ponyd (ponyd serve -i 0.0.0.0)
  2. use IP of your Mac in connectToURL (⌥+click on Wi-Fi icon to get your Mac's IP address)
gruhls508 commented 8 years ago

Ok that makes sense. Thanks @dstd