Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ERR_SPDY_PROTOCOL_ERROR #110

Closed
deevus opened this issue Oct 20, 2016 · 10 comments
Closed

ERR_SPDY_PROTOCOL_ERROR #110

deevus opened this issue Oct 20, 2016 · 10 comments

Comments

@deevus
Copy link

deevus commented Oct 20, 2016

Hi

I'm trying to integrate redux-api into an existing application. When I try to dispatch a sync action, I get a ERR_SPDY_PROTOCOL_ERROR in the console.

Any ideas what could be causing this? fetch works just fine outside of redux-api.

const headers = {
};

const options = (url, params, getState) => {
  const {user} = getState();
  const accessToken = getAccessToken(user, null);
  return {
    headers: Object.assign({
      "Authorization": `Bearer: ${accessToken}`
    }, headers)
  };
};

const api = reduxApi({
  events: {
    crud: true,
    options,
    url: `${API_URL}/api/Scoring/:fixtureId/Events`,
  }
});

export default api;
const onEnterScoring = (
  nextState: RouterState,
  replace: RedirectFunction,
  dispatch: Dispatch<any>,
  getState: Function,
  callback?: Function
) => {
  const {id} = nextState.params;
  const {events} = scoringApi.actions;
  try {
    events.sync({fixtureId: id})(dispatch, getState, null, callback);
  } catch (e) {
    // do nothing
  }

  callback();
};

I can see two dispatched actions in redux. One for the initial request action, then a failed request action.

@deevus
Copy link
Author

deevus commented Oct 20, 2016

I've also started some TS declarations that you might be interested in as per #93

@lexich
Copy link
Owner

lexich commented Oct 20, 2016

About ERR_SPDY_PROTOCOL_ERROR - for example https://www.wiknix.com/solved-err_spdy_protocol_error-in-chrome/ I think it's external problem.

About TS - you are welcome, make PR 👍

@lexich
Copy link
Owner

lexich commented Oct 20, 2016

Also you can't try error with try/catch

const onEnterScoring = (
  nextState: RouterState,
  replace: RedirectFunction,
  dispatch: Dispatch<any>,
  getState: Function,
  callback?: Function
) => {
  const {id} = nextState.params;
  const {events} = scoringApi.actions;
  //try {
  const request =
    events.sync({fixtureId: id})(dispatch, getState, null, callback);

  // if you want to catch error 
  request.catch((e)=> {
    console.error(e);
  });

  //} catch (e) {
    // do nothing
  //}

  //callback(); - callback should be call by sync
};

@deevus
Copy link
Author

deevus commented Oct 20, 2016

Thanks for the reply.

It also fails in Firefox, so it's not only Chrome. In Firefox, it comes up as "Aborted" in the Firebug net tab.

Even if it was a browser issue, it can't explain why fetch calls outside of redux-api are working.

@lexich
Copy link
Owner

lexich commented Oct 20, 2016

Your code looks like working. To understand reasons of error we need to go deeper and need more context. Redux-api makes the same fetch calls.

@deevus
Copy link
Author

deevus commented Oct 20, 2016

I'm using HTTPS with self-signed certificates. Could that have any bearing?

@lexich
Copy link
Owner

lexich commented Oct 20, 2016

I think, yes. Because redux-api with fetch adapter in the end makes fetch(${API_URL}/api/Scoring/:fixtureId/Events, { ...options }); And 95% that your problem is with environment.

@deevus
Copy link
Author

deevus commented Oct 20, 2016

The endpoint I'm calling is also HTTPS.

@deevus deevus closed this as completed Oct 20, 2016
@deevus
Copy link
Author

deevus commented Oct 20, 2016

LOL it was a typo

"Authorization": Bearer: ${accessToken}``

There should be no : after Bearer

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants
@deevus @lexich and others