Cannot Upload document to new Item - Upload Failed

637 views
Skip to first unread message

Mathieu Pelletier

unread,
Aug 19, 2021, 10:20:34 AM8/19/21
to DSpace Technical Support
I have been trying to squash this one for days now.  I have both backend and frontend servers running on the same machine.  Both are running secure via apache2 or Nginx proxy (yes, I tried both).

Here is what I see in the console:
[Error] WebSocket connection to 'wss://redacted2.ac.za/sockjs-node/673/beoy5t2y/websocket' failed: Unexpected response code: 400
[Error] Invalid Host/Origin header
error
error (vendor.js:127553)
(anonymous function) (vendor.js:97762)
(anonymous function) (vendor.js:166322)
(anonymous function) (vendor.js:133298)
(anonymous function) (vendor.js:134016)
forEach
(anonymous function) (vendor.js:134014)
(anonymous function)
(anonymous function) (vendor.js:133214)
(anonymous function) (vendor.js:135331)
(anonymous function) (vendor.js:133214)
(anonymous function) (vendor.js:135276)
(anonymous function) (vendor.js:133214)
(anonymous function) (vendor.js:135755)
(anonymous function)
(anonymous function) (vendor.js:133214)
(anonymous function) (vendor.js:134709)
wrapFn (polyfills.js:13605)
runTask (polyfills.js:12554)
invokeTask (polyfills.js:12867)
invokeTask (polyfills.js:14008)
globalZoneAwareCallback (polyfills.js:14034)
[Error] [WDS] Disconnected!
error
close (vendor.js:127556)
(anonymous function) (vendor.js:97741)
(anonymous function) (vendor.js:133298)
(anonymous function) (vendor.js:134098)
(anonymous function)
runTask (polyfills.js:12554)
invokeTask (polyfills.js:12867)
timer (polyfills.js:14939)

Here is what I have in local.cfg:

##########################

# SERVER CONFIGURATION   #

##########################


# DSpace installation directory.

# This is the location where you want to install DSpace.

# Windows note: Please remember to use forward slashes for all paths (e.g. C:/dspace)

dspace.dir=/data/dspace


# URL of DSpace backend ('server' webapp). Include port number etc.

# DO NOT end it with '/'.

# This is where REST API and all enabled server modules (OAI-PMH, SWORD,

# SWORDv2, RDF, etc) will respond.

dspace.server.url = https://redacted1.ac.za/server


# URL of DSpace frontend (Angular UI). Include port number etc.

# DO NOT end it with '/'.

# This is used by the backend to provide links in emails, RSS feeds, Sitemaps,

# etc.

dspace.ui.url = https://redacted2.ac.za


# Name of the site

dspace.name = Research Commons


# assetstore.dir, look at DSPACE/config/spring/api/bitstore.xml for more options

# default is ${dspace.dir}/assetstore, uncomment and modify if you need to use a different path

#assetstore.dir = assetstore


# Default language for metadata values

#default.language = en_US


# Solr server/webapp.

# DSpace uses Solr for all search/browse capability (and for usage statistics).

# Since DSpace 7, SOLR must be installed as a stand-alone service

solr.server = http://localhost:8983/solr


Here is what I have in environments.prod.ts:

export const environment = {

  // The "ui" section defines where you want Node.js to run/respond. It may correspond to your primary URL, but it also may not (if you are running b>

  // In this example, we are setting up our UI to just use localhost, port 4000.

  // This is a common setup for when you want to use Apache or Nginx to handle HTTPS and proxy requests to Node on port 4000

  ui: {

      ssl: false,

      host: 'localhost',

      port: 4000,

      // NOTE: Space is capitalized because 'namespace' is a reserved string in TypeScript

      nameSpace: '/'

  },

  // This example is valid if your Backend is publicly available at https://api.mydspace.edu/server/

  // The REST settings MUST correspond to the primary URL of the backend. Usually, this means they must be kept in sync

  // with the value of "dspace.server.url" in the backend's local.cfg

  rest: {

      ssl: true,

      host: 'redacted1.ac.za',

      port: 443,

      // NOTE: Space is capitalized because 'namespace' is a reserved string in TypeScript

      nameSpace: '/server'

  },


themes: [

 {

    name: 'mytheme'

 },

],


};


I have everything else working, it seems.  I have branded the site, I have created communities and collections, but I can't create items because I can't upload anything.  I have tried checking directory ownership and permissions in the underlying filesystem, but nothing seems to work.

I would appreciate some help if anyone has a clue as to what is going on.

Many thanks!


Tim Donohue

unread,
Aug 19, 2021, 11:42:10 AM8/19/21
to Mathieu Pelletier, DSpace Technical Support
Hi Mathieu,

If you can authenticate successfully & create other object (Communities/Collections), that implies that your main setup is correct​. If you had major configuration errors in your local.cfg (on backend) and/or environment.prod.ts (on frontend), then you would not be able to authenticate at all.

That said, it's not clear (to me) what might be the obvious problem with the upload process.  I'd recommend you check for errors in the logs on the backend.  Primarily check the dspace.log, but also look in the Apache / Tomcat / Nginx logs as well (in case more information can be found there).  

The Console error you posted is an odd one, as it's unclear why it'd throw an "Unexpected response code: 400, Invalid Host/Origin header".  You also might want to look closely at your proxy settings in Nginx.... googling that error brought me to this StackOverflow answer: https://stackoverflow.com/a/48096141   I admit, I'm not familiar enough with Nginx (I tend to use Apache), so I don't know if this could be the result of a bad proxy setting in Nginx.  

You also might want to be sure that nothing is blocking X-Forwarded-* headers in your Proxy... as it's also possible something like this is happening: https://wiki.lyrasis.org/display/DSDOC7x/Installing+DSpace#InstallingDSpace-MyRESTAPIisrunningunderHTTPS,butsomeofits%22link%22URLsareswitchingtoHTTP?

If you figure out the issue, please report back on the fix...it's possible you are hitting a Proxy configuration issue that others may also encounter -- in which case, I'd like to ensure it is more clearly documented in the Install docs.

Tim


From: dspac...@googlegroups.com <dspac...@googlegroups.com> on behalf of Mathieu Pelletier <mkpel...@gmail.com>
Sent: Thursday, August 19, 2021 9:20 AM
To: DSpace Technical Support <dspac...@googlegroups.com>
Subject: [dspace-tech] Cannot Upload document to new Item - Upload Failed
 
--
All messages to this mailing list should adhere to the Code of Conduct: https://www.lyrasis.org/about/Pages/Code-of-Conduct.aspx
---
You received this message because you are subscribed to the Google Groups "DSpace Technical Support" group.
To unsubscribe from this group and stop receiving emails from it, send an email to dspace-tech...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/dspace-tech/e63c965e-fc83-45be-8817-6fd75c78196dn%40googlegroups.com.

Mathieu Pelletier

unread,
Aug 24, 2021, 9:18:56 AM8/24/21
to DSpace Technical Support
I *finally* found the solution to this one.  I have been killing myself over this for a week now. This thread was helpful: https://groups.google.com/g/dspace-tech/c/o73FXQvumAw/m/L0RN8NcYCwAJ

I am running on a Debian based system (ubuntu) and ReadWrite access needs to be granted to Tomcat via the service file (/lib/systemd/system/tomcat9.service).  It is not enough to simply grant access to the user via the filesystem. You might want to add this to the setup documents as it took me forever to find this one.  The log detail was not providing anything useful at all so it was difficult to track down.  Also for the setup file, it seems that the default storage location ${dspace.dir}/assetstore is not created in the setup routines.  This is obvious enough if one explores the config files, but it is not discussed anywhere in the setup documentation (unless I overlooked it?).

I hope this saves someone else a heap of wasted time.

Best Regards,
Mathieu

Tim Donohue

unread,
Aug 24, 2021, 9:50:49 AM8/24/21
to Mathieu Pelletier, DSpace Technical Support
Thanks for the note, Mathieu.

I was not aware of that myself.  I just added a brief note to the Installation guide's Tomcat section here:
https://wiki.lyrasis.org/display/DSDOC7x/Installing+DSpace#InstallingDSpace-ServletEngine(ApacheTomcat9,Jetty,CauchoResinorequivalent)

See the bullet that starts "On Debian systems.."

Please review this and make sure it's correct... I didn't try it for myself, so it could use a second set of eyes.

Tim

Sent: Tuesday, August 24, 2021 8:18 AM

To: DSpace Technical Support <dspac...@googlegroups.com>
Subject: Re: [dspace-tech] Cannot Upload document to new Item - Upload Failed
 

Mathieu Pelletier

unread,
Aug 24, 2021, 10:18:58 AM8/24/21
to DSpace Technical Support
That looks right to me, Tim.  Thanks!
Reply all
Reply to author
Forward
0 new messages