AWPoll - Unable to reach the Ariba service.

61 views
Skip to first unread message

Kazz

unread,
Nov 21, 2016, 2:15:32 PM11/21/16
to AribaWeb (aribaweb.org)
Hi,

I'm developing an application which does OAuth 2 authentication with a trading application service.
The application does;

- Override AWComponent's renderResponse() where I check if the associated session has authenticated information (such as access token...), then if not authenticated, it redirects to a direct action which handle OAuth2 transaction. If authenticated, it calles super.renderResponse();

        Like this;

@Override
public void renderResponse(AWRequestContext requestContext, AWComponent component) {
OAuthSession session = (OAuthSession) requestContext.session();
String accessToken = session.sessionInfo.oauth2AccessToken;
Date expires = session.sessionInfo.expires;
if (accessToken == null) {
startAuth(requestContext, component);     // redirect to a direct action
} else if (expires != null && expires.before(new Date())) {
startAuth(requestContext, component);     // redirect to a direct action
} else {
super.renderResponse(requestContext, component);
}
}
}

- A page lists documents from the trading application service then download the documents and convert them to Excel spreadsheet for download.

- Because listing documents takes long time, it is done in another thread so that the application return a page quickly.

- The document list is stored in the session.

I don't want to expire the session, I added AWPoll on the page.
But the polling failed with PollDialog (it says "Unable to reach the Ariba service.").


Please point out if my approach is wrong/bad, or give my some advice how to inspect cause and to solve the problem.

Thank you,
Kazuo

Frantisek Kolar

unread,
Nov 21, 2016, 4:34:18 PM11/21/16
to arib...@googlegroups.com
Hi Kazuo, 

How did you register your pooling?  In AW you register a change notifier, optionally you set the pull interval and then notifying  a change should do the trick. I think in AW open source distribution there should be some examples too. 
Search for AWChangeNotifier

Thanks, 
Frank


--
You received this message because you are subscribed to the Google Groups "AribaWeb (aribaweb.org)" group.
To unsubscribe from this group and stop receiving emails from it, send an email to aribaweb+u...@googlegroups.com.
To post to this group, send email to arib...@googlegroups.com.
Visit this group at https://groups.google.com/group/aribaweb.
For more options, visit https://groups.google.com/d/optout.

Kazz

unread,
Nov 21, 2016, 8:12:48 PM11/21/16
to AribaWeb (aribaweb.org)
Hi Frank,

My code is like this,

In init() of the component,

super.init();
AWPage page = page();
Register page.getChangeNotifier() to aThread object
page.setPollInitiated(true);
page.setPollInterval(5);

....

In an action method,
aThread do real job and when the job finished, call notifyChange() of registered change notifier,

In overridden notifyChange() of the component,
Show banner message to notify the job completed.


Of course I checked examples in AW and have ever used this function several times in my AW experience since it's first release.

The instance runs on Ubuntu 14 in Amazon EC2.
I override initAdaptorUrl() of application class to set right URL for the instance.

Thanks,
Kazuo

Frantisek Kolar

unread,
Nov 21, 2016, 9:16:33 PM11/21/16
to arib...@googlegroups.com
If you have correctly setup as in the example, and you get a dialog “Unable to reach ariba service”, you need to do little debugging. 

1. I would start from Request.js:


function poll()
{
// FIXME -- should check interval since last request against interval
Debug.log("AWRequestInProgress: " + AWRequestInProgress + ", AWPollEnabled=" + AWPollEnabled);
if (!AWRequestInProgress && AWPollEnabled) {
if (this.AWPollCallback) {
this.AWPollCallback(this.AWPollState);
}
var url = this.formatInPageRequestUrl(AWPollSenderId);
// wrap the awLoadLazyDivCallback in an anonymous function so we can
// pass the additional divObject to it
this.initiateXMLHttpRequest(url, callback.bind(this));
} else {
// somebody else might have been using the XML http request too,
// so just in case we have multiple timers going, we clear the one we are
// aware of and then reset it to null so our timer starts the poll again
clearTimeout(AWPollTimeoutId);
AWPollTimeoutId = null;
timer();
}
}
And above poll()call, what the URL you have there and wheather its reachable. 

2. Then if you think the server is reachable, then another Breakpoint to put could be into the 
AWComponentActionRequestHandler.handleRequest()
which is the place where everything starts on the AW layers and continues deep into individual components. 


-FK





Kazz

unread,
Nov 23, 2016, 7:27:26 PM11/23/16
to AribaWeb (aribaweb.org)
Hi Frank,

Thank you for the advice.
I will do the debug later.

The following is the result from a simplified test.

The request sent from browser looks correct but show  "Unable to reach the Ariba service". (Application is deployed on bitnami tomcat on Amazon EC2)

The request was,
  1. Request URL:
  2. Request Method:
    GET
  3. Status Code:
    200 OK
  4. Remote Address:
The request header was,

  1. Accept:
    */*
  2. Accept-Encoding:
    gzip, deflate, sdch
  3. Accept-Language:
    ja,en-US;q=0.8,en;q=0.6
  4. Connection:
    keep-alive
  5. Content-type:
    text/html
  6. Cookie:
    awscreenstats=1920x1080; JSESSIONID=ACC97799A6B1B64F8F81CF9D2D99C852
  7. Host:
  8. Referer:
  9. User-Agent:
    Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/54.0.2840.71 Safari/537.36
The response was,

    <head/><AWPoll state='update'/>
     or
    <head/><AWPoll state='nochange'/>

The response header was,

  1. cache-control:
    max-age=0, no-cache, no-store, must-revalidate
  2. Connection:
    keep-alive
  3. Content-Length:
    33
  4. Content-Type:
    text/html;charset=UTF-8
  5. Date:
    Thu, 24 Nov 2016 00:16:56 GMT
  6. pragma:
    no-cache
  7. Server:
    Apache
  8. Vary:
    Accept-Encoding
  9. X-Mod-Pagespeed:
    1.9.32.14-0
The source of the component is,

public class Main extends AWComponent
{
    public static class Entry {
        public String name;
        public String comment;
    }

    public Entry _current = new Entry(), _item;
    public List<Entry> _entries = new ArrayList();
private AWChangeNotifier _changeNotifier;

    public void init() {
    super.init();
AWPage page = page();
_changeNotifier = page.getChangeNotifier();
page.setPollingInitiated(true);
page.setPollInterval(5);
    }
    
    public void notifyChange() {
    System.out.println("Changed");
    }
    
    public void add ()
    {
        _entries.add(_current);
        _current = new Entry();
        this.changed();
    }

private void changed() {
_changeNotifier.notifyChange();
}
}

2016年11月22日火曜日 11時16分33秒 UTC+9 František Kolář:

Kazz

unread,
Jan 17, 2017, 9:17:02 AM1/17/17
to AribaWeb (aribaweb.org)
My workaround is edit Request.js to handle "<head/>".

Thanks,

2016年11月24日木曜日 9時27分26秒 UTC+9 Kazz:
Reply all
Reply to author
Forward
0 new messages