Skip to content
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

Calling function while subscribed to events results in timeout #35

Open
JSchaenzle opened this issue Feb 21, 2016 · 5 comments
Open

Calling function while subscribed to events results in timeout #35

JSchaenzle opened this issue Feb 21, 2016 · 5 comments

Comments

@JSchaenzle
Copy link

I am using the latest release of the SDK, Version 0.3.4. For some reason, if my app subscribes to an event, I cannot seem to call functions (using callFunction)on my device. If I do not subscribe to the event, the function calls work perfectly and the completion block is called quickly as expected. When I subscribe to an event, the subscription works fine and my app receives events published from my device, however when I call a function, the call times out after about 20 seconds. The error info is below.

Has anyone experienced this? I haven't ruled out that it's something that I am doing wrong but I've been wrestling with this for a while and not making any progress. Are there any requirements about what thread you call callFunction from or subscribeToEventsWithPrefix()?

"Error Domain=NSURLErrorDomain Code=-1001 "The request timed out." UserInfo={NSUnderlyingError=0x7f9b6420e930 {Error Domain=kCFErrorDomainCFNetwork Code=-1001 "The request timed out." UserInfo={NSErrorFailingURLStringKey=https://api.particle.io/v1/devices/40002b000447343233323032/set-tc-temp, NSErrorFailingURLKey=https://api.particle.io/v1/devices/40002b000447343233323032/set-tc-temp, _kCFStreamErrorCodeKey=-2102, _kCFStreamErrorDomainKey=4, NSLocalizedDescription=The request timed out.}}, NSErrorFailingURLStringKey=https://api.particle.io/v1/devices/40002b000447343233323032/set-tc-temp, NSErrorFailingURLKey=https://api.particle.io/v1/devices/40002b000447343233323032/set-tc-temp, _kCFStreamErrorDomainKey=4, _kCFStreamErrorCodeKey=-2102, NSLocalizedDescription=The request timed out.}">

From my Podfile.lock:

  • Spark-SDK (0.3.4):
    • Spark-SDK/Helpers (= 0.3.4)
    • Spark-SDK/SDK (= 0.3.4)
  • Spark-SDK/Helpers (0.3.4)
  • Spark-SDK/SDK (0.3.4):
    • AFNetworking (< 3.0.0)
    • Spark-SDK/Helpers
@idokleinman
Copy link
Contributor

I will check it, thanks for reporting

@idokleinman
Copy link
Contributor

@JSchaenzle I tried reproducing this and could not - I was able to call a function on the photon device after being subscribed to an event stream without any issue. I assume you are doing something wrong. If you want me I will post the full iOS Swift code + photon firmware C code I created while trying to repro this issue, so you can maybe compare against and see if you did something wrong.

@JSchaenzle
Copy link
Author

@idokleinman Thanks for checking. I don't think it's necessary for you to post your code right now. I'll keep digging into it on my side. If I can find a simple process to reproduce the issue I'll let you know.

@idokleinman
Copy link
Contributor

For reference / other users, posting the C photon firmware code I used to test this issue:

int LED = D7;
int testVariable=64;

int testFunction(String command) {
    for (int i=0;i<5;i++) {
        digitalWrite(D7, HIGH);
        delay(100);
        digitalWrite(D7, LOW);
        delay(100);
    }
    Particle.publish("test-func-called");   
}

void setup() {
    pinMode(D7, OUTPUT);
    Particle.function("testFunc",testFunction);
    Particle.variable("testVar", &testVariable, INT);

}

void loop() {
    digitalWrite(D7, HIGH);
    delay(1000);
    digitalWrite(D7, LOW);
    delay(1000);
    Particle.publish("test-event");
}

@idokleinman
Copy link
Contributor

and the test code on iOS-land is here:
https://github.com/spark/spark-setup-ios-example/blob/master/SparkSetupExample-Swift/ViewController.swift#L93-L242

no issues encountered.
Update me if you find anything, otherwise I'm closing this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants