Meteor-files: Images are not displayed on production server

Created on 6 Jul 2016  Â·  22Comments  Â·  Source: veliovgroup/Meteor-Files

Hello,
on local server all works fine but when I load the image on production server, the image is not displayed.
File is the path specified in the ‘storagePath’ exists. I can remove the file in a standard way, for example trough a method.

Ubuntu-14.04-x86_64
Node v0.10.45
Meteor 1.3.4.1
blaze
fileURL used
ostrio:[email protected] (on 1.5.5 same problem)
ROOT_URL is set

Sorry for my English

Behind Proxy

Most helpful comment

Hello @yanickrochon ,

Wait... what? The new server address is 192.168.2.51, but the image source is set to the old IP. The record in the database does not store an IP, so where is this address coming from?

Have you updated ROOT_URL env var?

All 22 comments

  1. Where you're hosted? (VDS, dedicated, Modulus, Heroku etc..)
  2. OS?
  3. Enable debug and post its output
  4. With which error server is responded?
  5. Have you checked and set right permission on storagePath?
  6. Is fileURL helper returns right URL?

1_ VDS
2_ Ubuntu-14.04-x86_64
3_

// Client
[FilesCollection] [insert()]
[FilesCollection] [insert] [Tracker] [continue]
[FilesCollection] [insert] [.continue()]
[FilesCollection] [insert] using WebWorkers
loadFile c113d721f40c97d18a229048f26c0939.jpg: 140.517ms

// Server
[FilesCollection] [File Start Method] c113d721f40c97d18a229048f26c0939.jpg - i2K9YYrCS4b2hYXDG
[FilesCollection] [Upload] [Start Method] Got #-1/2 chunks, dst: c113d721f40c97d18a229048f26c0939.jpg
[FilesCollection] [Upload] [DDP] Got #2/2 chunks, dst: c113d721f40c97d18a229048f26c0939.jpg
[FilesCollection] [Upload] [DDP] Got #1/2 chunks, dst: c113d721f40c97d18a229048f26c0939.jpg
[FilesCollection] [Upload] [DDP] Got #-1/2 chunks, dst: c113d721f40c97d18a229048f26c0939.jpg
[FilesCollection] [Upload] [finish(ing)Upload] -> /opt/images/product_images/i2K9YYrCS4b2hYXDG.jpg
[FilesCollection] [Upload] [finish(ed)Upload] -> /opt/images/product_images/i2K9YYrCS4b2hYXDG.jpg

4_ No erros
5_ User under which the node is running has the right ALL=(ALL) NOPASSWD:ALL
6_ Yes

Place ostrio:files higher in .meteor/packages

Now place ostrio:files right after ecmascript and I have same problem

2016-07-06 17 55 28
2016-07-06 17 55 45

  1. Response code is 200 ?
  2. On server you should have logs with download() and serve(), do you have them?
  3. Are you behind Nginx, Passenger or any other proxy-server?
  1. No, I get en error in Chrome console: net::ERR_NAME_NOT_RESOLVED
  2. No, I don`t have them.
  3. No, just only Node sudo forever-service install -s /opt/myapp/bundle/main.js -e 'PORT=80 MONGO_URL=mongodb://localhost:27017/myapp ROOT_URL=http://app.myapp.ru METEOR_ENV=production' myapp

Maybe it's because of a subdomain?

net::ERR_NAME_NOT_RESOLVED check your DNS records.
what nslookup app.myapp.ru says?

nslookup app.myapp.ru says:

Non-authoritative answer:
Name: app.myapp.ru
Address: IP attached to the app.myapp.ru

net::ERR_NAME_NOT_RESOLVED I get this error only images. Everything else is working properly

Previously you've said there is no .download() and .serve() logs. This means your request even not reaches MF package on server. Have you checked dns and nslookup from your "client" machine, not the server itself?
What if you will use Google Public DNS on your "client" machine?

Yes, the problem is in the DNS... It took less then 48 horses when I did write A record.
I replaced the temporary ROOT_URL on the IP. Now everything is working!

Thanks for the package!

Hi @dmitry0117
I'm glad you solved this issue.

Please, support this project by:

Hi everyone,

I got the same probleme as @dmitry0117 but for some weird reason all pictures are displaying when my user is connected.

Here is my mup file :

module.exports = {
  servers: {
    one: {
      host: 'X.X.X.X',
      username: 'xxxx',
      password: 'xxxxx'
    }
  },
  meteor: {
    name: 'app',
    path: '../../app',
    servers: {
      one: {}
    },
    buildOptions: {
      serverOnly: true,
      debug: true,
      cleanAfterBuild: true
    },
    volumes:{
      '/images':'/images'
    },
    env: {
      ROOT_URL: 'https://rebnautic.com',
      MONGO_URL: 'mongodb://localhost/meteor',
    },
    docker: {
      image: 'kadirahq/meteord:base'
    },
    deployCheckWaitTime: 100,
    deployCheckPort: 100,
    enableUploadProgressBar: true
  },

  mongo: {
    oplog: true,
    port: 27017,
    version: '3.2.7',
    servers: {
      one: {},
    },
  }
};

My Image.js file :

Images = new FilesCollection({
  collectionName: 'Images',
  allowClientCode: false,
  storagePath: '/images',
  debug:true,
  allowClientCode: true,
    permissions: 0777,
  parentDirPermissions: 0777,
  downloadCallback: function(){
    return !!this.userId;
  },
  onBeforeUpload: function (file) {
    // Allow upload files under 10MB, and only in png/jpg/jpeg formats
    if (file.size <= 10485760 && /png|jpg|jpeg/i.test(file.extension)) {
      return true;
    } else {
      return 'Please upload image, with size equal or less than 10MB';
    }
  }
});

When debug is set to true:

[FilesCollection] [find({}, undefined)]
ostrio_files.js?hash=d2c5c48…:2573 [FilesCollection] [find({}, undefined)]
ostrio_files.js?hash=d2c5c48…:2573 [FilesCollection] [find({"meta.bateau":"nAyQSrLQJkbNcwtA2"}, undefined)]
ostrio_files.js?hash=d2c5c48…:946 [FilesCollection] [FilesCursor] [fetch()]
8HGGXEnuCQpiQv9fk.jpg:1 GET http://10.1.18.229:3000/cdn/storage/Images/8HGGXEnuCQpiQv9fk/original/8HGGXEnuCQpiQv9fk.jpg 404 (Not Found)

As I told you, when i'm logged to my website, all my pictures are displaying correctly. But 404 code when i'm loggout.

The problem still here on dev mode.

My config :

Ubuntu-14.04-x86_64
Meteor 1.4.4.3
fileURL set
ostrio:[email protected] (on 1.7.8 same problem)
ROOT_URL is set

Thanks and sorry for my english

Hello @AlexCln ,

This is right behavior, you're returning false from downloadCallback hook when user isn't logged in. See downloadCallback docs.

Hi @dr-dimitru,

Thanks for the reply. You right ! I've made a mistake in my code. Here is my corrected Image collection file :
Images = new FilesCollection({ collectionName: 'Images', allowClientCode: false, storagePath: '/images', debug:true, allowClientCode: true, permissions: 0777, parentDirPermissions: 0777, downloadCallback: function(){ return true; }, onBeforeUpload: function (file) { // Allow upload files under 10MB, and only in png/jpg/jpeg formats if (file.size <= 10485760 && /png|jpg|jpeg/i.test(file.extension)) { return true; } else { return 'Please upload image, with size equal or less than 10MB'; } } });

Hope that my code will help someone else.

Have a good day
Alex

Hello @AlexCln ,

Great I'm glad you issue is solved,
Please, support this project by:

However it does not work for me. I had to upgrade the production server, so I reinstalled the app, and everything started just fine, but when I opened the app in the browser, there were no images whatsoever.

I have tried uploading another image, thinking that something might've got wrong in the db backup process, but no; even new uploaded images don't display.

Everything worked ffine before, and does work fine in development. But no images are displayed in production anymore.

The error is : Failed to load resource: net::ERR_ADDRESS_UNREACHABLE

The image URL looks like this : http://192.168.1.50/cdn/storage/users.avatars/8uF768xpLPt9De5EA/original/8uF768xpLPt9De5EA and if I paste the same image in development (i.e. http://localhost:3000/cdn/storage/users.avatars/8uF768xpLPt9De5EA/original/8uF768xpLPt9De5EA), the image does show.

I don't understand what's wrong.

Wait... what? The new server address is 192.168.2.51, but the image source is set to the old IP. The record in the database does not store an IP, so where is this address coming from?

Hello @yanickrochon ,

Wait... what? The new server address is 192.168.2.51, but the image source is set to the old IP. The record in the database does not store an IP, so where is this address coming from?

Have you updated ROOT_URL env var?

Argh. Gawd dammit! :stuck_out_tongue:

@yanickrochon please confirm after a while what everything works fine just by updating ROOT_URL.

And what this upgrade was about? Server upgrade or Meteor/Node upgrade?

Yes, everything is fine, now. The app was running in two VM (Meteor and MongoDB), but we are migrating to a different infrastructure, and it doesn't make any sense, now to have this setup. So I prepared another single VM for the app, with some brand new Bash scripts. The change of IP is because the app is now running on a different, dedicated VLAN (i.e. the app is accessed by handheld devices within the factory, and I don't want pesky users to connect via their cell phones or other devices). Anyhow. It was a silly mistake; I had forgotten about this var in mup.js

Was this page helpful?
0 / 5 - 0 ratings