0

I have recently begun toying with OpenCPU and I must admit I am very impressed with it. Though, I have run into a strange problem.

When I try to access an application that I am currently working on, on my laptop, everything is fine. But when I do it on a mobile device, I get an error.

"Connection to OpenCPU failed: error"

Any thoughts on why the error is occurring? I have uploaded an example to www.ttbjerring.com

Best, Bjerring

Bjerring
  • 35
  • 4
  • Might be a CORS or mixed content problem. Try using the http (not https) opencpu server when calling from a http page. – Jeroen Ooms Sep 20 '14 at 12:22
  • Unfortunately, it didn't solve the problem. I have tried investigate it in a little more detail. I have tried replicating the "hello world" example from the tutorial on the OpenCPU web-page (http://ttbjerring.com/app1.html), and the error continues to occur. I then tried accessing other websites using CORS (ocpu.seturl), and they all suffer from the same error. Though, the error does not occur when I access apps on the OpenCPU webpage, so the error seems to have something to do with CORS. – Bjerring Sep 22 '14 at 06:22
  • Which mobile browser are you using? If it has a development mode or javascript console, you can probably see some warnings/errors in there. – Jeroen Ooms Sep 22 '14 at 09:42
  • So after a bit more digging around, it seems that the Safari browser on windows gives the same error as I experience when using my standard android mobile browser. The error also seems to occur on mobile devices using the chrome mobile browser and safari mobile browser. This is what I see in the console: Setting path to CORS server opencpu-0.4.js:386 http://public.opencpu.org/ocpu/library/appdemo/R Location response header missing. opencpu-0.4.js:144 X-ocpu-session response header missing. opencpu-0.4.js:145 TypeError: 'undefined' is not an object (evaluation 'loc.match') opencpu-0.4.js:149 – Bjerring Sep 23 '14 at 05:52
  • Here is a small pic of what I see: https://dl.dropboxusercontent.com/u/5906261/pic.jpg – Bjerring Sep 23 '14 at 05:59
  • Seems like Safari doesn't do CORS properly. Strange. I'll try to figure out what is going on. – Jeroen Ooms Sep 23 '14 at 10:18
  • Thank you very much for looking into it. I am really impressed with OpenCPU, and can see unlimited potential for it's application in catalysing scientific computing - both in academia and in the industry. – Bjerring Sep 23 '14 at 13:54
  • Let's continue the discussion on email. Can you send a message to me or the mailing list (whatever you prefer) ? – Jeroen Ooms Sep 23 '14 at 20:02
  • sure, that might be a good idea. I will send you a message later today. – Bjerring Sep 24 '14 at 13:09

1 Answers1

0

Some debugging and google reveals that there are multiple problems with the CORS implementation in older versions of Safari. The main issue seems to be that the client can not read the Location header:

All of this has been fixed in more recent versions of Safari. Do note that Safari for windows is no longer supported by Apple. The latest Windows version (Safari 5) was released in June 2010, with a final patch release 5.1.7 in May 2012. So it has not been updated for over two years.

Now Safari Mobile is more problematic of course. I don't have an iphone/ipad myself, but it would be helpful to further narrow this down. Which version of Safari/IOS are you using? Did you get a chance to test this on a more recent versions of Safari Mobile? It would be nice to have a workaround, but it might not be easy.

I did push and deploy a small fix for another problem that Safari seemed to be having in some cases, but I doubt this will solve any of your problems.

Jeroen Ooms
  • 31,998
  • 35
  • 134
  • 207