@nuclearpideon excellent work! I totally agree with all your hunches – that this is due in part to the browser, as well as due to browserify. Browserify will substitute some of the HTTP request functions, and then those functions get limited mileage as far as browser compatibility.
I’d like to reiterate – and I’d be interested to see if anyone else can confirm – the fact that I find Safari in El Capitan to be working if I replace http.request with xhr before browserifying.
First of all, Congratulations for such an incredible job.
I have tried photonsoftapmeteor and http://23.253.54.117/setup/ in Chrome, Firefox and Internet Explorer in a Windows 8.1 machine but it never finds the Photon.
The laptop is connected to the photon wireless network and it is also connected to Internet by Ethernet.
Possibly slightly off topic here, but relevant to hosting services in AP mode:
The softap implementation starts a dns_redirector service. What redirections does it do? How can this be configured?
My usecase: I’d like to redirect all requests to the photon ip, or, I want to redirect a specific domain or hostname.
I haven’t been able to configure a Photon using Safari OR Chrome on my iPad. Both attempt to reload photonsoftap.meteor.com immediately after hitting the “Connect” button. After setting up Safari on my Mac to debug further, it seems that there’s some kind of error during encryption of the password, after which the page immediately tries to refresh:
I could debug further but I’d have to clone and run my own version of the app.
The POST /configure-ap issue may run deeper than Safari itself. I’m having the same issue with Phonegap. (i.e. compiled as an apk for Android it works fine, but compiled as a ipa for iOS the command does nothing).
Note I’m using jQuery.ajax directly.
$.ajax(this.props.base_url + '/configure-ap', {
method: "POST",
timeout: 8000,
data: JSON.stringify(jsonData),
processData: false,
contentType: "multipart/form-data",
success: (data) => {
if(data.r === 0){
this.connect();
} else {
this.setState({
alertType: "danger",
alertMsg: "Your device rejected the credentials. Please try again. If this problem persists contact technical support."
});
}
},
error: () => {
this.setState({
alertType: "danger",
alertMsg: "Error sending credentials to your device. Verify your connection with the device and try again."
});
}
});
I’ve configured Photons successfully using the Meteor app on OSX, Windows, and Android devices, just never Safari or Chrome on iOS.
Ugh, it looks like this particular issue goes pretty deep. Using the Safari debugger, I traced the error to this section of code inside softap.browserify.js, which comes from the original rsa.js library:
var crypto = global.crypto || global.msCrypto // 3
if(crypto && crypto.getRandomValues) { // 4
module.exports = randomBytes; // 5
} else { // 6
module.exports = oldBrowser; // 7
} // 8
function randomBytes(size, cb) { // 9
var bytes = new Buffer(size); //in browserify, this is an extended Uint8Array
/* This will not work in older browsers. // 11
* See https://developer.mozilla.org/en-US/docs/Web/API/window.crypto.getRandomValues
*/ // 13
// 14
crypto.getRandomValues(bytes); // 15
if (typeof cb === 'function') { // 16
return process.nextTick(function () { // 17
cb(null, bytes); // 18
}); // 19
} // 20
return bytes; // 21
} // 22
Specifically, line 15 is where the error happens. I can recreate this from the console:
It looks like the “extended Uint8Array” passed into getRandomValues is at fault:
I’ll investigate the possible fixes in that issue more.
Please! Can someone help me or telling me what I am doing bad:
I have tried photonsoftapmeteor and http://23.253.54.117/setup/4 in Chrome, Firefox and Internet Explorer in a Windows 8.1 machine but it never finds the Photon.
The core is in listening mode, the laptop is connected to the photon wireless network and it is also connected to Internet by Ethernet.
Do I have to change the Photon Firmware or it would be work with the original one? Any help will be apreciated.
@mebrunet While there’s a small difference in Accept-Language, I think at this point we may fairly retire the hypothesis that the HTTP server configuration is to blame.
I can confirm @indraastra 's errors. Further, I am seeing errors stemming from Uint8Array being thrown from inside the Browserify shim for XHR (where it handles responses) as well!
I think, at this point, we are seeing a pervasive JS problem centered on the way different browsers handle Buffer() and Uint8Array. That’s why we’re seeing problems in RSA land, as well as the slightly less abstruse XHR land.
I have to disagree. I think it’s precisely a bug with the Photon’s (or Broadcom’s) HTTP sever that is causing this problem.
If the raw TCP communication stream contains the same essential information, differing only in the order of the headers, some capitalization… etc. Then it’s likely some obscure bug related either to those differences, or some other lower-level differences in the way the HTTP protocol is being executed/interpreted (e.g. TCP/IP headers). Keep in mind those TCP streams were raw network traffic… by the time Wireshark picks them up the browser isn’t changing anything about them anymore.
Additionally, other HTTP servers seem to have no problem extracting JSON POST data from both Safari and Chrome. So it’s quite hard not to point the finger at the Photon. Whether the issue lies with Particle’s firmware or Broadcom’s underlying WICKED SDK remains TBD.
(Note: I made sure “pwd” field passed by Safari in the above capture was able to get the Photon working with Chrome - so you can rule out an RSA issue in this case.)
@mebrunet: Aha, this is exactly why I asked the question. I should have nipped it in the bud yesterday to save you the probably migraine-inducing debug session of diffing these two TCP streams. If you still have the streams or can recreate them, look at the individual TCP packets and see if Safari sends two packets: one with the HTTP header only, and one with the request body. This is the issue I ran into with my react-native app and posted about here:
Basically, the requests are reconstructed by every debugging tool to be nearly identical apart from a few inconsequential headers because they ARE valid. The problem is that the HTTP server doesn't treat them the same at the packet level. Hopefully, that's what you're running into as well.