
I made a function that downloads file from url and uploads to pomf.lain.la, but it keeps giving one of following two errors.
TypeScript
[ERROR] FetchError: request to https://pomf.lain.la/upload.php failed, reason: socket hang up
[ERROR] FetchError: request to https://pomf.lain.la/upload.php failed, reason: read ECONNRESET
This is my code:
TypeScript
async function uploadToPomf(url) {
const fileResponse = await fetch(url);
if (!fileResponse.ok) throw new Error('File download failed');
const buffer = await fileResponse.arrayBuffer();
const contentType = fileResponse.headers.get('content-type');
const ext = contentType.startsWith('video') ? 'mp4' : 'webp';
console.log(`[POMF] Uploading ${ext} file...`);
console.log(`[POMF] Content-Type: ${contentType}`);
console.log(`[POMF] Buffer size: ${buffer.byteLength} bytes`);
const form = new FormData();
form.append('files[]', Buffer.from(buffer), {
filename: `file_${Date.now()}.${ext}`,
contentType: contentType,
knownLength: buffer.length
});
const pomfResponse = await fetch('https://pomf.lain.la/upload.php', {
method: 'POST',
body: form,
headers: form.getHeaders()
});
console.log(`[POMF] ${pomfResponse.status} ${await pomfResponse.text()}`);
if (!pomfResponse.ok) throw new Error(`HTTP ${pomfResponse.status}`);
const pomfData = await pomfResponse.json();
if (!pomfData.success) throw new Error('Pomf upload failed');
return pomfData.files[0].url;
}
Even following code gives same error
TypeScript
const testResponse = await fetch('https://pomf.lain.la/upload.php', {
method: 'HEAD',
timeout: 10000
});
How can I fix this? Does this mean pomf.lain.la blocked appwrite cloud functions ip?
TL;DR
The developers are facing "socket hang up" and "ECONNRESET" errors when trying to upload files to "pomf.lain.la". They suspect that the appwrite cloud functions IP might be blocked. The issue might be due to a connection problem or rate limiting from the server, and not necessarily IP blocking.
Possible solutions:
1. Check if there are any rate limits or restrictions on the server side.
2. Ensure that the connection to "pomf.lain.la" is stable and reliable.
3. Try adding a delay between requests to avoid overwhelming the server.
4. Implement error handling and retryRecommended threads
- GitHub connected; functions not recogniz...
So basically this is my first time using Appwrite functions and my appwrite account was made eith GitHub sign in I create a startup function and in the connect ...
- Cannot find module failure
Sorry, Newbe question here. I just installed Appwrite and am trying to install my first Function an am having absolutely no luck what-so-ever getting this done...
- Email Verification Email
Hi everyone, I’m currently experiencing an issue with the email verification functionality. When I trigger the verification, the request returns a valid respon...
