I’m trying to connect my plugin to the server using fetch to get some data back.
This works well in my computer (WINDOWS)
I had a test with a Mac user (havent’ tried with another Mac user) that seems his computer cannot connect to the server. We already tried checking the enabling extensions to connect to internet but doesn’t solve the problem.
Here’s the code I use to fetch data from my server, this works well on Windows but I’m having an Issue on Mac with this user:
const response = await fetch("https://compositenation.com:5000" + '/activate', {
method: 'POST',
headers: {
'Accept': 'application/json, text/plain, */*',
'Content-Type': 'application/json',
},
body: JSON.stringify({
someData: "someData"
})
}).then(async (res) => {
// Do something with res...
}).then(async data => {
// Do something...
}).catch(async e => {
await DialogAlert(e.stack, "error");
return;
});
This code does’t even pass to the the first .then() code block. I thought it was the body and changed to something easy but seems that that isn’t the issue and it gives me this error:
Imma try with another Mac computers but haven’t had the chance as I only have a Windows computer and need a user with a Mac to help me to see if the pattern is with all Macs or only on this one.
‘curl’ also works ‘http’ but not ‘https’ as follows.
$ curl -X POST https://compositenation.com:5000/activate -H “Content-Type: text/plain” -d “HAHA”
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:–:-- --:–:-- --:–:-- 0
curl: (35) OpenSSL/1.1.1t: error:1408F10B:SSL routines:ssl3_get_record:wrong version number
On macOS, both ‘http’ & ‘https’ not work.
fetch("https://compositenation.com:5000" + '/activate', {
method: 'POST',
headers: {
'Accept': 'application/json, text/plain, */*',
'Content-Type': 'application/json',
},
body: JSON.stringify({
someData: "someData"
})
})
.then(response => response.text())
.then(text => console.log(text))
.catch(e => console.log(e));
Promise {<pending>}
fetch("http://compositenation.com:5000" + '/activate', {
method: 'POST',
headers: {
'Accept': 'application/json, text/plain, */*',
'Content-Type': 'application/json',
},
body: JSON.stringify({
someData: "someData"
})
})
.then(response => response.text())
.then(text => console.log(text))
.catch(e => console.log(e));
Promise {<pending>}
VM38:13 TypeError: Network request failed
at XMLHttpRequest.xhr.onerror (fetch.js:568:1)
at XMLHttpRequest.inlineListener (EventUtils.js:44:1)
at EventTargetDispatch.js:232:1
at Object.runWithNativeHandler (<anonymous>)
at _dispatchNodeEvent (EventTargetDispatch.js:226:1)
at _dispatchInternalCaptureEvent (EventTargetDispatch.js:146:1)
at dispatchInternalEvent (EventTargetDispatch.js:98:1)
at dispatchTrustedEvent (EventTargetDispatch.js:259:1)
at dispatch (XMLHttpRequest.js:867:1)
VM43:13 TypeError: Network request failed
at XMLHttpRequest.xhr.onerror (fetch.js:568:1)
at XMLHttpRequest.inlineListener (EventUtils.js:44:1)
at EventTargetDispatch.js:232:1
at Object.runWithNativeHandler (<anonymous>)
at _dispatchNodeEvent (EventTargetDispatch.js:226:1)
at _dispatchInternalCaptureEvent (EventTargetDispatch.js:146:1)
at dispatchInternalEvent (EventTargetDispatch.js:98:1)
at dispatchTrustedEvent (EventTargetDispatch.js:259:1)
at dispatch (XMLHttpRequest.js:867:1)
The reason for the failure is “The request timed out”.
These are the things I can check on UXP side now. Maybe you need to look at the server side.
One thing to note is that macOS PS does not support ‘HTTP’ protocol now.
I already tried using “https” instead of “http” in the featch link for Mac computers but I get the same error. Is this something I need to make it work around or is this a bug from UXP? I’m really stuck having tons of mails of users wanting to use the UXP version but mac users are not able to do it because this error I’m having.
What type of protocol I could use or how I could fix this issue on my end? @mykim
‘https’ is recommended as it’s secure.
Please do test your HTTPS URL with some popular tools such as ‘curl’, ‘wget’ or ‘nmap’.
It looks like compositenation.com:5000 is not available. We cannot help if the server is not running properly. ‘wget’ or ‘curl’ should be able to receive response from your server.
nmap -v compositenation.com -p 5000
…
PORT STATE SERVICE
5000/tcp filtered upnp
filtered (from manual page)
Nmap cannot determine whether the port is open because packet filtering prevents its probes from reaching the port. The filtering could be from a dedicated firewall device, router rules, or host-based firewall software. These ports frustrate attackers because they provide so little information. Sometimes they respond with ICMP error messages such as type 3 code 13 (destination unreachable: communication administratively prohibited), but filters that simply drop probes without responding are far more common. This forces Nmap to retry several times just in case the probe was dropped due to network congestion rather than filtering. This slows down the scan dramatically.
Only HTTPS is supported on macOS due to app security restrictions. I recommend always using HTTPS.
Your site does not appear to support HTTPS when using port 5000. I recommend reconfiguring your load balancer to support TLS on port 5000 or simply use the default port (443).