Article View: news.software.nntp
Article #51480Re: NNTP Commands Question
From: Curt Welch
Date: Mon, 26 Mar 2001 06:44
Date: Mon, 26 Mar 2001 06:44
154 lines
9215 bytes
9215 bytes
"Darrell Davis" <darrell.davis@usa.net> wrote: > Actually no, this time I did mean message-ids. This is getting > confusing. Should I use article number instead? Yes. > Keep track of the > highest contiguous article number received? Yes. Bascially. > So if I receive article > number 99 and 101, keep 99 as my high water mark. Not exactly. > So a server should > never reuse article numbers correct? Bascially. But not exactly. > RFC 977 doesn't say anything about > how servers keep track of article numbers. That's my only reference so > far. None of the references give you the real-world experience you need to write it correctly. But I'll give you a free lesson because I haven't answered many questions like this in some time so I guess it's my turn. :) To start with, yes you should use article numbers to figure out which articles you have read/downloaded and which ones you haven't read. When servers receive a new article for a group, it gets assigned the next highest article number. The article numbers just keep couting up higher and higher. Article numbers are 32 bit numbers (minus one for the sign bit). So they can count up to 2^31. For real groups, it would take hundreds of years to overflow that counter, so the fact that it keeps counting up isn't a problem. All servers keep their own article numbers. When you install/build a new server, the artile numbers all start at 0 (or 1). But sometimes admins will start the numbers at a different value for some special reason. A server will never reuse an article number. Once an article is assigned a number, that number will never get used again. BUT, if the news server crashes for example, or is replaced with new hardware, it's possible that all the article numbers will start over at 0. Or at some other number the news admin sets. So, it's possible that one day, you look at a group, like news.software.nttp, and the articles may be in the range 10000 to 11220. Then the next day, you check the server, and find the articles are now numbered 1 to 56 for some unknown reason. It's important for your software not to think it's highwater mark is 11220 and wait for the articles to count back up to that point before trying to download new articles again. The NNTP GROUP command will give you the valid range for articles currently in the group -- the current low and high article numbers. In theory, these numbers will never go down. Every time you check them, you should see the range the same, or the numbers should be higher (the low number moves up as articles are expired, the high moves up as new articles come in). But you never know what might really happen on some of the larger complex servers. Your software should not blow up just because the high water mark is one less right now than it was 5 minutes ago, or if the low water mark when down. What is safe to assume is that the only articles you should try to read are the ones which fall within the range returned by the GROUP command. And the other thing that's save is that once you read/download article N, you will never need to check for it again to see if it might be a different article. When you try to read articles in the GROUOP range, you will get errors for some of them. The main and "normal" reason this happens is because that either 1) articles were canceled, 2) they expired out of order. Both of these things are normal expected behavior from news servers. And with these erros, it means that once you try to read the article, if the server tells you it's gone, then there's no point in trying again because it really is gone and will never come back. i.e. you missed it and there's nothing you can do about it. If you read articles 99 and 101, but 100 is reported as missing, then you would normally assume it is missing and will never show up. But, with the bug as talked about above, sometimes article show up out of order. This happens because some news servers are actually made up of multiple servers. The articles were assigned numbers in-order as they were received on the first server, but then they are sent to a second server which is using the numbers assigned by the first server. Articles commonly get sent in ways that allow them to show up on the second server out of order. So article 101 may show up before 100. But on a normal working server, this time delay will be seconds at most. And these gaps will only happen for the new articles (near the high water mark). These servers BTW are broken. But they do exist. And if it's important to never mis an article, your software needs to recheck the old gaps. But you don't need to keep re-checking them for days and days. If the gap hasn't been filled withing an hour or so, it's not likely to ever be filled. You have to decide for yourself how you software will deal with that and how much re-checking you feel is justified. If you just trying to download everything from a group, then all you need to do is use the GROUP and ARTICLE commands. Your software will keep track of the highwater mark of what it's downloaded, and maybe a bit more to help it correctly spot article number resets, and to know what missing articles from last time may need to be checked for again on this pass. But, if you want to select articles to download, (or to not download) based on things like subject or author, then you might start using XOVER. And there are issues there. XOVER returns the data from some of the most commonly used headers. And if the command is working correctly, will correctly report which articles are avalable and which are missing - and that should be consistent with what happens when you try to fetch the article with the ARTICLE command. But on all to many servers, it's not. It's all too common for broken servers to return XOVER data for articles which were long ago deleted. And some servers that aren't configued correctly may not return XOVER data for articles even though they are still available on the server. Just be aware of these issues when you write your code and don't assume everything is perfect. Then there's the time issue. News servers constantly receive new articles and are constly removing articles (in the range of 15 per second for a full feed). The low and high article numbers for a group will be changing as your software is trying to download stuff. So once again, be aware of this and make sure you code doesn't expect it to remain constent. For example, don't do two GROUP commands and expect the numbers to be the same both times. And don't be surprised if you try to read and article and you get a different response code because the article is out of range, (not just missing). It may have been in range when you did the group command 3 ms ago, but it's out of range now. Response codes is another pain in the butt with NNTP programming. There are standards, but none of the servers match any of the RFCs (for all codes). Most are fairly consistent, but there are execeptions. The only way you will find them all is to do a lot of testing on as many different servers as you can. Mostly, the response codes that say something "worked" will be the same, but the error codes will vary more wildly. Just once again, don't expect the server to only return one and only one fixed code. Now, having said all this, if you don't really need to do it all "right", and just want to get a basic suck feed working (which is what we call a client which simply downloads all new articles from groups) for a single server, then all you need to do is use the GROUP and ARTICLE commands, and keep track of the highest article downloaded so far for each group. Don't worry about everything else I've said and it will work fine 99.9% of the time. :) -- Curt Welch http://CurtWelch.Com/ curt@kcwc.com Webmaster for http://NewsReader.Com/
Technical Details
Message-ID:
<20010326014442.722$u4@newsreader.com>Path:
mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.nntp.mbox.zip!supernews.google.com!sn-xit-03!supernews.com!nntp.cs.ubc.ca!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!howland.erols.net!portc.blue.aol.com.MISMATCH!portc01.blue.aol.com!feed.newsreader.com!news2.newsreader.com!flame.newsreader.com!not-for-mailReferences:
<3abbee87$1@carrock.netin.com> <878zlvnbse.fsf@erlenstar.demon.co.uk> <3abc1704$1@carrock.netin.com> <87g0g3ltdw.fsf@erlenstar.demon.co.uk> <3abe8721$1@carrock.netin.com>Show Full Headers
Complete Article Headers
Message-ID: <20010326014442.722$u4@newsreader.com>
Subject: Re: NNTP Commands Question
Date: Mon, 26 Mar 2001 06:44:42 +0000
From: curt@kcwc.com (Curt Welch)
References: <3abbee87$1@carrock.netin.com> <878zlvnbse.fsf@erlenstar.demon.co.uk> <3abc1704$1@carrock.netin.com> <87g0g3ltdw.fsf@erlenstar.demon.co.uk> <3abe8721$1@carrock.netin.com>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.nntp.mbox.zip!supernews.google.com!sn-xit-03!supernews.com!nntp.cs.ubc.ca!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!howland.erols.net!portc.blue.aol.com.MISMATCH!portc01.blue.aol.com!feed.newsreader.com!news2.newsreader.com!flame.newsreader.com!not-for-mail
Organization: NewsReader.Com
Newsgroups: news.software.nntp
X-User: Curt@NewsReader.Com
X-Face: "p}G*1KH{+F7EYGKLb>ogDguabZ+%,?^epeFB!nzu`)`$=QcvL1KF6<0GH!Tbc!Sqo[|tV5
%IW48mQf3K=Ci&gZ7]]aazx@]Y-nq!r5{yH/#,?@lDdUDvOfByB2hVW0.@OM%{l/{cT'{w
X-Url: http://CurtWelch.Com/
User-Agent: NewsReader.Com
Lines: 153