[TIMOB-24017] iOS: Add support for headers to the log server
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | High |
Status | Closed |
Resolution | Fixed |
Resolution Date | 2016-10-13T10:21:09.000+0000 |
Affected Version/s | n/a |
Fix Version/s | Release 6.0.0 |
Components | iOS, Tooling |
Labels | n/a |
Reporter | Chris Barber |
Assignee | Chris Barber |
Created | 2016-10-11T23:19:51.000+0000 |
Updated | 2017-03-20T17:11:06.000+0000 |
Description
When a client connects to the log server in the iOS app, it would helpful for the server to immediately respond with information about the app including the app id, version, environment (sim/device), and deploy type.
The format can be simple and basically mimic how HTTP works. When a new connection is accepted, it would immediately write:
id: com.foo.bar
name: Testapp
version: 1.0.0
deploy-type: development
titanium-sdk: 6.0.0
The client will interpret all lines prior to \n\n
to be a header. Subsequent lines are to be interpreted as log lines.
We need this feature so that a client can validate it has connected to the correct log server. It's possible for two different apps to listen on the same work and a client may think it's connecting to one app's log server when in fact it's connecting to another app's log server.
Published ioslib@1.0.2 PR: https://github.com/appcelerator/ioslib/pull/50
TiSDK master PR: https://github.com/appcelerator/titanium_mobile/pull/8503 TiSDK 6_0_X PR: https://github.com/appcelerator/titanium_mobile/pull/8504 To test:
Create an app called "testapp1"
Add
<log-server-port>12345</log-server-port>
in the<ios>
section of the tiapp.xmlBuild app for device
LEAVE CLI, SIM, & APP RUNNING!
Open 2nd terminal
Create an app called "testapp2"
Add
<log-server-port>12345</log-server-port>
in the<ios>
section of the tiapp.xmlBuild app for device
NOTE: The app ids must be different. It should error when the CLI tries to 2nd app tries to connect to the 2nd app's log server.I used the test step after scons'ing the PR from 6_0_X. doesn't error out, still logging independently of each other. [~hansknoechel] if you have time test it out too?
OK, so this is probably impossible to test with the simulator because my code is too smart. If you look at the build log output for the first app, it will select the port 12345. However, if you look at the build log output for the 2nd app, it will say a different port than 12345. Why is this you might ask? The build starts a local Node.js server to make sure that the port is available since the iOS Simulator shares ports with the local machine. For device builds, we can't tell if a port is available unless we try connecting to it. We could test the port, but this is not foolproof. If testapp1 is not running when testapp2 is building, but testapp1 is launched while testapp2 is being installed, then you'll still run into the problem that this ticket attempts to solve. So, if you do the above steps for a device build, it should show the error for the 2nd app.
Great work! APPROVED!
Closing ticket as fixed.