# Possible timeout in parseAsArrayBuffer

**URL:** https://discourse.vtk.org/t/possible-timeout-in-parseasarraybuffer/9470
**Category:** Support
**Created:** [September 27, 2022, 1:07pm UTC](https://discourse.vtk.org/t/possible-timeout-in-parseasarraybuffer/9470 "2022-09-27T13:07:50Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![riddlexter](https://discourse.vtk.org/user_avatar/discourse.vtk.org/riddlexter/32/5844_2.png) [@riddlexter](https://discourse.vtk.org/u/riddlexter)
#### Post date: [September 27, 2022, 1:07pm UTC](https://discourse.vtk.org/t/possible-timeout-in-parseasarraybuffer/9470/1 "2022-09-27T13:07:50Z")

</div>

Is there a timeout in parseAsArrayBuffer from ITKImageReader? Because when I try to get data from a slow server it gives error in Promise, but if I get the same file from a local server it works well, no problems, both using a fetch command.

Best,  
Rodrigo

---

<div class="post-metadata">

### Author: ![Forrest](https://discourse.vtk.org/user_avatar/discourse.vtk.org/forrest/32/300_2.png) [@Forrest](https://discourse.vtk.org/u/Forrest)
#### Post date: [September 27, 2022, 3:03pm UTC](https://discourse.vtk.org/t/possible-timeout-in-parseasarraybuffer/9470/2 "2022-09-27T15:03:28Z")

</div>

What error are you getting? My first thought is that there is some CORS issue with fetching from the slow server, whereas you don’t have those issues with the local server.

---

<div class="post-metadata">

### Author: ![riddlexter](https://discourse.vtk.org/user_avatar/discourse.vtk.org/riddlexter/32/5844_2.png) [@riddlexter](https://discourse.vtk.org/u/riddlexter)
#### Post date: [September 27, 2022, 7:51pm UTC](https://discourse.vtk.org/t/possible-timeout-in-parseasarraybuffer/9470/3 "2022-09-27T19:51:44Z")

</div>

It gives this error…

 ![image](https://discourse.vtk.org/uploads/default/original/2X/b/bf02a1b63093490ce6f0a7d415202299ac017c17.png)

The slow server is in fact a Orthanc server, and I pull nifti images from it. If I download the nifti file and use a local file server it works, but direct from Orthanc gives this problem.

The code I use

async function get(url)  
{  
const response = await fetch(url, { mode: ‘no-cors’});  
return response.arrayBuffer();  
}

let idSerie = ‘203887c1-80b36d9f-7fc1be71-75bc3420-0aab6659’;  
if (userParams.serieid)  
idSerie = userParams.serieid;

let filename = idSerie + ‘.nii.gz’;  
let url = ‘[http://10.36.0.182:8042/series/](http://10.36.0.182:8042/series/)’ + idSerie + ‘/nifti?compress’;  
url = ‘[http://10.36.0.182:8080/](http://10.36.0.182:8080/)’ + filename;

const reader = vtkITKImageReader.newInstance();  
reader.setFileName(filename);

get(url).then((arrayBuffer) =\> {  
reader.parseAsArrayBuffer(arrayBuffer).then(() =\> {  
reader.update();  
// wire up the reader to the mapper  
mapper.setInputConnection(reader.getOutputPort());  
renderer.addVolume(actor);  
// — Reset camera and render the scene —  
renderer.resetCamera();  
renderWindow.render();  
});

global.renderWindow = renderWindow;  
global.renderer = renderer;  
global.actor = actor;  
global.mapper = mapper;  
});

---

<div class="post-metadata">

### Author: ![Forrest](https://discourse.vtk.org/user_avatar/discourse.vtk.org/forrest/32/300_2.png) [@Forrest](https://discourse.vtk.org/u/Forrest)
#### Post date: [September 28, 2022, 3:33pm UTC](https://discourse.vtk.org/t/possible-timeout-in-parseasarraybuffer/9470/4 "2022-09-28T15:33:04Z")

</div>

Fetching with `no-cors` will return an opaque Response object, meaning you won’t get any data. You will need to properly configure CORS in order to fetch data.

---

<div class="post-metadata">

### Author: ![riddlexter](https://discourse.vtk.org/user_avatar/discourse.vtk.org/riddlexter/32/5844_2.png) [@riddlexter](https://discourse.vtk.org/u/riddlexter)
#### Post date: [September 28, 2022, 7:51pm UTC](https://discourse.vtk.org/t/possible-timeout-in-parseasarraybuffer/9470/5 "2022-09-28T19:51:10Z")

</div>

It worked!!! Thanks !!!  
In case anyone suffering the same problem I made a little example how to create a docker nginx to add CORS to Orthanc. Only need to edit properly conf.d/app.conf file. If you interest, you can ask me. I dont have permission to upload it right now…

Best,  
Rodrigo
